1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Enabled modules for InvoiceController.php

This commit is contained in:
Benjamin Beganović 2021-06-17 14:43:14 +02:00
parent 2d9bd6471b
commit a502cee73e
5 changed files with 70 additions and 35 deletions

View File

@ -12,8 +12,9 @@
namespace App\Http\Controllers\ClientPortal; namespace App\Http\Controllers\ClientPortal;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Requests\ClientPortal\ProcessInvoicesInBulkRequest; use App\Http\Requests\ClientPortal\Invoices\ShowInvoicesRequest;
use App\Http\Requests\ClientPortal\ShowInvoiceRequest; use App\Http\Requests\ClientPortal\Invoices\ProcessInvoicesInBulkRequest;
use App\Http\Requests\ClientPortal\Invoices\ShowInvoiceRequest;
use App\Models\Invoice; use App\Models\Invoice;
use App\Utils\Number; use App\Utils\Number;
use App\Utils\TempFile; use App\Utils\TempFile;
@ -33,7 +34,7 @@ class InvoiceController extends Controller
* *
* @return Factory|View * @return Factory|View
*/ */
public function index() public function index(ShowInvoicesRequest $request)
{ {
return $this->render('invoices.index'); return $this->render('invoices.index');
} }

View File

@ -0,0 +1,31 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Http\Requests\ClientPortal\Invoices;
use App\Http\ViewComposers\PortalComposer;
use Illuminate\Foundation\Http\FormRequest;
class ProcessInvoicesInBulkRequest extends FormRequest
{
public function authorize()
{
return auth('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES;
}
public function rules()
{
return [
'invoices' => ['array'],
];
}
}

View File

@ -9,9 +9,10 @@
* @license https://www.elastic.co/licensing/elastic-license * @license https://www.elastic.co/licensing/elastic-license
*/ */
namespace App\Http\Requests\ClientPortal; namespace App\Http\Requests\ClientPortal\Invoices;
use App\Http\Requests\Request; use App\Http\Requests\Request;
use App\Http\ViewComposers\PortalComposer;
class ShowInvoiceRequest extends Request class ShowInvoiceRequest extends Request
{ {
@ -22,6 +23,7 @@ class ShowInvoiceRequest extends Request
*/ */
public function authorize() : bool public function authorize() : bool
{ {
return auth('contact')->user()->client->id == $this->invoice->client_id; return auth('contact')->user()->client->id == $this->invoice->client_id
&& auth('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES;
} }
} }

View File

@ -0,0 +1,31 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Http\Requests\ClientPortal\Invoices;
use App\Http\ViewComposers\PortalComposer;
use Illuminate\Foundation\Http\FormRequest;
class ShowInvoicesRequest extends FormRequest
{
public function authorize()
{
return auth('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES;
}
public function rules()
{
return [
//
];
}
}

View File

@ -1,30 +0,0 @@
<?php
namespace App\Http\Requests\ClientPortal;
use Illuminate\Foundation\Http\FormRequest;
class ProcessInvoicesInBulkRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true; // TODO.
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'invoices' => ['array'],
];
}
}