mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-09 20:52:56 +01:00
Moving permissions to form requests
This commit is contained in:
parent
c144a1c604
commit
05bd8d9318
@ -1,4 +1,4 @@
|
|||||||
<?php namespace app\Commands;
|
<?php namespace App\Commands;
|
||||||
|
|
||||||
abstract class Command
|
abstract class Command
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace app\Console\Commands;
|
<?php namespace App\Console\Commands;
|
||||||
|
|
||||||
use File;
|
use File;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace app\Console\Commands;
|
<?php namespace App\Console\Commands;
|
||||||
|
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use App\Services\BankAccountService;
|
use App\Services\BankAccountService;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace app\Console;
|
<?php namespace App\Console;
|
||||||
|
|
||||||
use Utils;
|
use Utils;
|
||||||
use Illuminate\Console\Scheduling\Schedule;
|
use Illuminate\Console\Scheduling\Schedule;
|
||||||
|
@ -146,10 +146,8 @@ class ClientController extends BaseController
|
|||||||
*
|
*
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function create()
|
public function create(ClientRequest $request)
|
||||||
{
|
{
|
||||||
$this->authorizeCreate();
|
|
||||||
|
|
||||||
if (Client::scope()->withTrashed()->count() > Auth::user()->getMaxNumClients()) {
|
if (Client::scope()->withTrashed()->count() > Auth::user()->getMaxNumClients()) {
|
||||||
return View::make('error', ['hideHeader' => true, 'error' => "Sorry, you've exceeded the limit of ".Auth::user()->getMaxNumClients()." clients"]);
|
return View::make('error', ['hideHeader' => true, 'error' => "Sorry, you've exceeded the limit of ".Auth::user()->getMaxNumClients()." clients"]);
|
||||||
}
|
}
|
||||||
@ -175,9 +173,7 @@ class ClientController extends BaseController
|
|||||||
public function edit(ClientRequest $request)
|
public function edit(ClientRequest $request)
|
||||||
{
|
{
|
||||||
$client = $request->entity();
|
$client = $request->entity();
|
||||||
|
|
||||||
$this->authorize('edit', $client);
|
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'client' => $client,
|
'client' => $client,
|
||||||
'method' => 'PUT',
|
'method' => 'PUT',
|
||||||
|
@ -12,6 +12,7 @@ use App\Models\Client;
|
|||||||
use App\Services\CreditService;
|
use App\Services\CreditService;
|
||||||
use App\Ninja\Repositories\CreditRepository;
|
use App\Ninja\Repositories\CreditRepository;
|
||||||
use App\Http\Requests\CreateCreditRequest;
|
use App\Http\Requests\CreateCreditRequest;
|
||||||
|
use App\Http\Requests\CreditRequest;
|
||||||
|
|
||||||
class CreditController extends BaseController
|
class CreditController extends BaseController
|
||||||
{
|
{
|
||||||
@ -55,23 +56,21 @@ class CreditController extends BaseController
|
|||||||
return $this->creditService->getDatatable($clientPublicId, Input::get('sSearch'));
|
return $this->creditService->getDatatable($clientPublicId, Input::get('sSearch'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create($clientPublicId = 0)
|
public function create(CreditRequest $request)
|
||||||
{
|
{
|
||||||
$this->authorizeCreate();
|
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
'clientPublicId' => Input::old('client') ? Input::old('client') : $clientPublicId,
|
'clientPublicId' => Input::old('client') ? Input::old('client') : ($request->client_id ?: 0),
|
||||||
//'invoicePublicId' => Input::old('invoice') ? Input::old('invoice') : $invoicePublicId,
|
|
||||||
'credit' => null,
|
'credit' => null,
|
||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
'url' => 'credits',
|
'url' => 'credits',
|
||||||
'title' => trans('texts.new_credit'),
|
'title' => trans('texts.new_credit'),
|
||||||
//'invoices' => Invoice::scope()->with('client', 'invoice_status')->orderBy('invoice_number')->get(),
|
'clients' => Client::scope()->with('contacts')->orderBy('name')->get(),
|
||||||
'clients' => Client::scope()->with('contacts')->orderBy('name')->get(), );
|
);
|
||||||
|
|
||||||
return View::make('credits.edit', $data);
|
return View::make('credits.edit', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
public function edit($publicId)
|
public function edit($publicId)
|
||||||
{
|
{
|
||||||
$credit = Credit::scope($publicId)->firstOrFail();
|
$credit = Credit::scope($publicId)->firstOrFail();
|
||||||
@ -90,7 +89,8 @@ class CreditController extends BaseController
|
|||||||
|
|
||||||
return View::make('credit.edit', $data);
|
return View::make('credit.edit', $data);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
public function store(CreateCreditRequest $request)
|
public function store(CreateCreditRequest $request)
|
||||||
{
|
{
|
||||||
$credit = $this->creditRepo->save($request->input());
|
$credit = $this->creditRepo->save($request->input());
|
||||||
|
@ -17,6 +17,8 @@ use App\Models\Expense;
|
|||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Services\ExpenseService;
|
use App\Services\ExpenseService;
|
||||||
use App\Ninja\Repositories\ExpenseRepository;
|
use App\Ninja\Repositories\ExpenseRepository;
|
||||||
|
|
||||||
|
use App\Http\Requests\ExpenseRequest;
|
||||||
use App\Http\Requests\CreateExpenseRequest;
|
use App\Http\Requests\CreateExpenseRequest;
|
||||||
use App\Http\Requests\UpdateExpenseRequest;
|
use App\Http\Requests\UpdateExpenseRequest;
|
||||||
|
|
||||||
@ -69,17 +71,16 @@ class ExpenseController extends BaseController
|
|||||||
return $this->expenseService->getDatatableVendor($vendorPublicId);
|
return $this->expenseService->getDatatableVendor($vendorPublicId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create($vendorPublicId = null, $clientPublicId = null)
|
public function create(ExpenseRequest $request)
|
||||||
{
|
{
|
||||||
$this->authorizeCreate();
|
if ($request->vendor_id != 0) {
|
||||||
|
$vendor = Vendor::scope($request->vendor_id)->with('vendorcontacts')->firstOrFail();
|
||||||
if($vendorPublicId != 0) {
|
|
||||||
$vendor = Vendor::scope($vendorPublicId)->with('vendorcontacts')->firstOrFail();
|
|
||||||
} else {
|
} else {
|
||||||
$vendor = null;
|
$vendor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
'vendorPublicId' => Input::old('vendor') ? Input::old('vendor') : $vendorPublicId,
|
'vendorPublicId' => Input::old('vendor') ? Input::old('vendor') : $request->vendor_id,
|
||||||
'expense' => null,
|
'expense' => null,
|
||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
'url' => 'expenses',
|
'url' => 'expenses',
|
||||||
@ -87,20 +88,18 @@ class ExpenseController extends BaseController
|
|||||||
'vendors' => Vendor::scope()->with('vendorcontacts')->orderBy('name')->get(),
|
'vendors' => Vendor::scope()->with('vendorcontacts')->orderBy('name')->get(),
|
||||||
'vendor' => $vendor,
|
'vendor' => $vendor,
|
||||||
'clients' => Client::scope()->with('contacts')->orderBy('name')->get(),
|
'clients' => Client::scope()->with('contacts')->orderBy('name')->get(),
|
||||||
'clientPublicId' => $clientPublicId,
|
'clientPublicId' => $request->client_id,
|
||||||
);
|
);
|
||||||
|
|
||||||
$data = array_merge($data, self::getViewModel());
|
$data = array_merge($data, self::getViewModel());
|
||||||
|
|
||||||
return View::make('expenses.edit', $data);
|
return View::make('expenses.edit', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function edit($publicId)
|
public function edit(ExpenseRequest $request)
|
||||||
{
|
{
|
||||||
$expense = Expense::scope($publicId)->with('documents')->firstOrFail();
|
$expense = $request->entity();
|
||||||
|
|
||||||
$this->authorize('edit', $expense);
|
|
||||||
|
|
||||||
$expense->expense_date = Utils::fromSqlDate($expense->expense_date);
|
$expense->expense_date = Utils::fromSqlDate($expense->expense_date);
|
||||||
|
|
||||||
$actions = [];
|
$actions = [];
|
||||||
@ -108,15 +107,6 @@ class ExpenseController extends BaseController
|
|||||||
$actions[] = ['url' => URL::to("invoices/{$expense->invoice->public_id}/edit"), 'label' => trans("texts.view_invoice")];
|
$actions[] = ['url' => URL::to("invoices/{$expense->invoice->public_id}/edit"), 'label' => trans("texts.view_invoice")];
|
||||||
} else {
|
} else {
|
||||||
$actions[] = ['url' => 'javascript:submitAction("invoice")', 'label' => trans("texts.invoice_expense")];
|
$actions[] = ['url' => 'javascript:submitAction("invoice")', 'label' => trans("texts.invoice_expense")];
|
||||||
|
|
||||||
/*
|
|
||||||
// check for any open invoices
|
|
||||||
$invoices = $task->client_id ? $this->invoiceRepo->findOpenInvoices($task->client_id) : [];
|
|
||||||
|
|
||||||
foreach ($invoices as $invoice) {
|
|
||||||
$actions[] = ['url' => 'javascript:submitAction("add_to_invoice", '.$invoice->public_id.')', 'label' => trans("texts.add_to_invoice", ["invoice" => $invoice->invoice_number])];
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$actions[] = \DropdownButton::DIVIDER;
|
$actions[] = \DropdownButton::DIVIDER;
|
||||||
@ -131,7 +121,7 @@ class ExpenseController extends BaseController
|
|||||||
'vendor' => null,
|
'vendor' => null,
|
||||||
'expense' => $expense,
|
'expense' => $expense,
|
||||||
'method' => 'PUT',
|
'method' => 'PUT',
|
||||||
'url' => 'expenses/'.$publicId,
|
'url' => 'expenses/'.$expense->public_id,
|
||||||
'title' => 'Edit Expense',
|
'title' => 'Edit Expense',
|
||||||
'actions' => $actions,
|
'actions' => $actions,
|
||||||
'vendors' => Vendor::scope()->with('vendorcontacts')->orderBy('name')->get(),
|
'vendors' => Vendor::scope()->with('vendorcontacts')->orderBy('name')->get(),
|
||||||
@ -155,9 +145,7 @@ class ExpenseController extends BaseController
|
|||||||
{
|
{
|
||||||
$data = $request->input();
|
$data = $request->input();
|
||||||
$data['documents'] = $request->file('documents');
|
$data['documents'] = $request->file('documents');
|
||||||
|
|
||||||
$this->authorizeUpdate($data);
|
|
||||||
|
|
||||||
$expense = $this->expenseService->save($data);
|
$expense = $this->expenseService->save($data);
|
||||||
|
|
||||||
Session::flash('message', trans('texts.updated_expense'));
|
Session::flash('message', trans('texts.updated_expense'));
|
||||||
@ -174,9 +162,7 @@ class ExpenseController extends BaseController
|
|||||||
{
|
{
|
||||||
$data = $request->input();
|
$data = $request->input();
|
||||||
$data['documents'] = $request->file('documents');
|
$data['documents'] = $request->file('documents');
|
||||||
|
|
||||||
$this->authorizeUpdate($data);
|
|
||||||
|
|
||||||
$expense = $this->expenseService->save($data);
|
$expense = $this->expenseService->save($data);
|
||||||
|
|
||||||
Session::flash('message', trans('texts.created_expense'));
|
Session::flash('message', trans('texts.created_expense'));
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace app\Http\Controllers;
|
<?php namespace App\Http\Controllers;
|
||||||
|
|
||||||
use Utils;
|
use Utils;
|
||||||
use View;
|
use View;
|
||||||
|
@ -25,6 +25,7 @@ use App\Ninja\Repositories\AccountRepository;
|
|||||||
use App\Ninja\Mailers\ContactMailer;
|
use App\Ninja\Mailers\ContactMailer;
|
||||||
use App\Services\PaymentService;
|
use App\Services\PaymentService;
|
||||||
|
|
||||||
|
use App\Http\Requests\PaymentRequest;
|
||||||
use App\Http\Requests\CreatePaymentRequest;
|
use App\Http\Requests\CreatePaymentRequest;
|
||||||
use App\Http\Requests\UpdatePaymentRequest;
|
use App\Http\Requests\UpdatePaymentRequest;
|
||||||
|
|
||||||
@ -67,10 +68,8 @@ class PaymentController extends BaseController
|
|||||||
return $this->paymentService->getDatatable($clientPublicId, Input::get('sSearch'));
|
return $this->paymentService->getDatatable($clientPublicId, Input::get('sSearch'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create($clientPublicId = 0, $invoicePublicId = 0)
|
public function create(PaymentRequest $request)
|
||||||
{
|
{
|
||||||
$this->authorizeCreate();
|
|
||||||
|
|
||||||
$invoices = Invoice::scope()
|
$invoices = Invoice::scope()
|
||||||
->where('is_recurring', '=', false)
|
->where('is_recurring', '=', false)
|
||||||
->where('is_quote', '=', false)
|
->where('is_quote', '=', false)
|
||||||
@ -79,8 +78,8 @@ class PaymentController extends BaseController
|
|||||||
->orderBy('invoice_number')->get();
|
->orderBy('invoice_number')->get();
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
'clientPublicId' => Input::old('client') ? Input::old('client') : $clientPublicId,
|
'clientPublicId' => Input::old('client') ? Input::old('client') : ($request->client_id ?: 0),
|
||||||
'invoicePublicId' => Input::old('invoice') ? Input::old('invoice') : $invoicePublicId,
|
'invoicePublicId' => Input::old('invoice') ? Input::old('invoice') : ($request->invoice_id ?: 0),
|
||||||
'invoice' => null,
|
'invoice' => null,
|
||||||
'invoices' => $invoices,
|
'invoices' => $invoices,
|
||||||
'payment' => null,
|
'payment' => null,
|
||||||
@ -94,12 +93,10 @@ class PaymentController extends BaseController
|
|||||||
return View::make('payments.edit', $data);
|
return View::make('payments.edit', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function edit($publicId)
|
public function edit(PaymentRequest $request)
|
||||||
{
|
{
|
||||||
$payment = Payment::scope($publicId)->firstOrFail();
|
$payment = $request->entity();
|
||||||
|
|
||||||
$this->authorize('edit', $payment);
|
|
||||||
|
|
||||||
$payment->payment_date = Utils::fromSqlDate($payment->payment_date);
|
$payment->payment_date = Utils::fromSqlDate($payment->payment_date);
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
@ -109,7 +106,7 @@ class PaymentController extends BaseController
|
|||||||
->with('client', 'invoice_status')->orderBy('invoice_number')->get(),
|
->with('client', 'invoice_status')->orderBy('invoice_number')->get(),
|
||||||
'payment' => $payment,
|
'payment' => $payment,
|
||||||
'method' => 'PUT',
|
'method' => 'PUT',
|
||||||
'url' => 'payments/'.$publicId,
|
'url' => 'payments/'.$payment->public_id,
|
||||||
'title' => trans('texts.edit_payment'),
|
'title' => trans('texts.edit_payment'),
|
||||||
'paymentTypes' => Cache::get('paymentTypes'),
|
'paymentTypes' => Cache::get('paymentTypes'),
|
||||||
'clients' => Client::scope()->with('contacts')->orderBy('name')->get(), );
|
'clients' => Client::scope()->with('contacts')->orderBy('name')->get(), );
|
||||||
@ -589,9 +586,7 @@ class PaymentController extends BaseController
|
|||||||
public function store(CreatePaymentRequest $request)
|
public function store(CreatePaymentRequest $request)
|
||||||
{
|
{
|
||||||
$input = $request->input();
|
$input = $request->input();
|
||||||
|
|
||||||
$this->authorizeUpdate($input);
|
|
||||||
|
|
||||||
$input['invoice_id'] = Invoice::getPrivateId($input['invoice']);
|
$input['invoice_id'] = Invoice::getPrivateId($input['invoice']);
|
||||||
$input['client_id'] = Client::getPrivateId($input['client']);
|
$input['client_id'] = Client::getPrivateId($input['client']);
|
||||||
$payment = $this->paymentRepo->save($input);
|
$payment = $this->paymentRepo->save($input);
|
||||||
@ -608,11 +603,7 @@ class PaymentController extends BaseController
|
|||||||
|
|
||||||
public function update(UpdatePaymentRequest $request)
|
public function update(UpdatePaymentRequest $request)
|
||||||
{
|
{
|
||||||
$input = $request->input();
|
$payment = $this->paymentRepo->save($request->input());
|
||||||
|
|
||||||
$this->authorizeUpdate($input);
|
|
||||||
|
|
||||||
$payment = $this->paymentRepo->save($input);
|
|
||||||
|
|
||||||
Session::flash('message', trans('texts.updated_payment'));
|
Session::flash('message', trans('texts.updated_payment'));
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ class TaskController extends BaseController
|
|||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'task' => null,
|
'task' => null,
|
||||||
'clientPublicId' => Input::old('client') ? Input::old('client') : $clientPublicId,
|
'clientPublicId' => Input::old('client') ? Input::old('client') : ($clientPublicId ?: 0),
|
||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
'url' => 'tasks',
|
'url' => 'tasks',
|
||||||
'title' => trans('texts.new_task'),
|
'title' => trans('texts.new_task'),
|
||||||
|
@ -23,6 +23,7 @@ use App\Models\Country;
|
|||||||
use App\Ninja\Repositories\VendorRepository;
|
use App\Ninja\Repositories\VendorRepository;
|
||||||
use App\Services\VendorService;
|
use App\Services\VendorService;
|
||||||
|
|
||||||
|
use App\Http\Requests\VendorRequest;
|
||||||
use App\Http\Requests\CreateVendorRequest;
|
use App\Http\Requests\CreateVendorRequest;
|
||||||
use App\Http\Requests\UpdateVendorRequest;
|
use App\Http\Requests\UpdateVendorRequest;
|
||||||
|
|
||||||
@ -38,8 +39,6 @@ class VendorController extends BaseController
|
|||||||
|
|
||||||
$this->vendorRepo = $vendorRepo;
|
$this->vendorRepo = $vendorRepo;
|
||||||
$this->vendorService = $vendorService;
|
$this->vendorService = $vendorService;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -77,11 +76,7 @@ class VendorController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function store(CreateVendorRequest $request)
|
public function store(CreateVendorRequest $request)
|
||||||
{
|
{
|
||||||
$data = $request->input();
|
$vendor = $this->vendorService->save($request->input());
|
||||||
|
|
||||||
$this->authorizeUpdate($data);
|
|
||||||
|
|
||||||
$vendor = $this->vendorService->save($data);
|
|
||||||
|
|
||||||
Session::flash('message', trans('texts.created_vendor'));
|
Session::flash('message', trans('texts.created_vendor'));
|
||||||
|
|
||||||
@ -94,12 +89,10 @@ class VendorController extends BaseController
|
|||||||
* @param int $id
|
* @param int $id
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function show($publicId)
|
public function show(VendorRequest $request)
|
||||||
{
|
{
|
||||||
$vendor = Vendor::withTrashed()->scope($publicId)->with('vendorcontacts', 'size', 'industry')->firstOrFail();
|
$vendor = $request->entity();
|
||||||
|
|
||||||
$this->authorize('view', $vendor);
|
|
||||||
|
|
||||||
Utils::trackViewed($vendor->getDisplayName(), 'vendor');
|
Utils::trackViewed($vendor->getDisplayName(), 'vendor');
|
||||||
|
|
||||||
$actionLinks = [
|
$actionLinks = [
|
||||||
@ -125,10 +118,8 @@ class VendorController extends BaseController
|
|||||||
*
|
*
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function create()
|
public function create(VendorRequest $request)
|
||||||
{
|
{
|
||||||
$this->authorizeCreate();
|
|
||||||
|
|
||||||
if (Vendor::scope()->count() > Auth::user()->getMaxNumVendors()) {
|
if (Vendor::scope()->count() > Auth::user()->getMaxNumVendors()) {
|
||||||
return View::make('error', ['hideHeader' => true, 'error' => "Sorry, you've exceeded the limit of ".Auth::user()->getMaxNumVendors()." vendors"]);
|
return View::make('error', ['hideHeader' => true, 'error' => "Sorry, you've exceeded the limit of ".Auth::user()->getMaxNumVendors()." vendors"]);
|
||||||
}
|
}
|
||||||
@ -151,16 +142,14 @@ class VendorController extends BaseController
|
|||||||
* @param int $id
|
* @param int $id
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function edit($publicId)
|
public function edit(VendorRequest $request)
|
||||||
{
|
{
|
||||||
$vendor = Vendor::scope($publicId)->with('vendorcontacts')->firstOrFail();
|
$vendor = $request->entity();
|
||||||
|
|
||||||
$this->authorize('edit', $vendor);
|
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'vendor' => $vendor,
|
'vendor' => $vendor,
|
||||||
'method' => 'PUT',
|
'method' => 'PUT',
|
||||||
'url' => 'vendors/'.$publicId,
|
'url' => 'vendors/'.$vendor->public_id,
|
||||||
'title' => trans('texts.edit_vendor'),
|
'title' => trans('texts.edit_vendor'),
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -193,11 +182,7 @@ class VendorController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function update(UpdateVendorRequest $request)
|
public function update(UpdateVendorRequest $request)
|
||||||
{
|
{
|
||||||
$data = $request->input();
|
$vendor = $this->vendorService->save($request->input());
|
||||||
|
|
||||||
$this->authorizeUpdate($data);
|
|
||||||
|
|
||||||
$vendor = $this->vendorService->save($data);
|
|
||||||
|
|
||||||
Session::flash('message', trans('texts.updated_vendor'));
|
Session::flash('message', trans('texts.updated_vendor'));
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace app\Http\Middleware;
|
<?php namespace App\Http\Middleware;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace app\Http\Middleware;
|
<?php namespace App\Http\Middleware;
|
||||||
|
|
||||||
use Request;
|
use Request;
|
||||||
use Closure;
|
use Closure;
|
||||||
|
@ -1,26 +1,18 @@
|
|||||||
<?php namespace App\Http\Requests;
|
<?php namespace App\Http\Requests;
|
||||||
|
|
||||||
class ClientRequest extends BaseRequest {
|
class ClientRequest extends EntityRequest {
|
||||||
|
|
||||||
protected $entityType = ENTITY_CLIENT;
|
protected $entityType = ENTITY_CLIENT;
|
||||||
|
|
||||||
public function entity()
|
public function entity()
|
||||||
{
|
{
|
||||||
return parent::entity()->load('contacts');
|
$client = parent::entity();
|
||||||
|
|
||||||
|
// eager load the contacts
|
||||||
|
if ($client && ! count($client->contacts)) {
|
||||||
|
$client->load('contacts');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $client;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public function authorize()
|
|
||||||
{
|
|
||||||
return $this->user()->can('view', $this->entity());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the validation rules that apply to the request.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function rules()
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace app\Http\Requests;
|
<?php namespace App\Http\Requests;
|
||||||
|
|
||||||
use App\Http\Requests\Request;
|
use App\Http\Requests\Request;
|
||||||
use Illuminate\Validation\Factory;
|
use Illuminate\Validation\Factory;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php namespace App\Http\Requests;
|
<?php namespace App\Http\Requests;
|
||||||
|
|
||||||
class CreateCreditRequest extends BaseRequest
|
class CreateCreditRequest extends EntityRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Determine if the user is authorized to make this request.
|
* Determine if the user is authorized to make this request.
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
<?php namespace app\Http\Requests;
|
<?php namespace App\Http\Requests;
|
||||||
|
|
||||||
use App\Http\Requests\Request;
|
class CreateExpenseRequest extends ExpenseRequest
|
||||||
use Illuminate\Validation\Factory;
|
|
||||||
|
|
||||||
class CreateExpenseRequest extends Request
|
|
||||||
{
|
{
|
||||||
// Expenses
|
// Expenses
|
||||||
/**
|
/**
|
||||||
@ -13,7 +10,7 @@ class CreateExpenseRequest extends Request
|
|||||||
*/
|
*/
|
||||||
public function authorize()
|
public function authorize()
|
||||||
{
|
{
|
||||||
return true;
|
return $this->user()->can('create', ENTITY_EXPENSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace app\Http\Requests;
|
<?php namespace App\Http\Requests;
|
||||||
|
|
||||||
use Auth;
|
use Auth;
|
||||||
use App\Http\Requests\Request;
|
use App\Http\Requests\Request;
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
<?php namespace app\Http\Requests;
|
<?php namespace App\Http\Requests;
|
||||||
|
|
||||||
use App\Http\Requests\Request;
|
|
||||||
use Illuminate\Validation\Factory;
|
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
|
|
||||||
class CreatePaymentRequest extends Request
|
class CreatePaymentRequest extends PaymentRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Determine if the user is authorized to make this request.
|
* Determine if the user is authorized to make this request.
|
||||||
@ -13,7 +11,7 @@ class CreatePaymentRequest extends Request
|
|||||||
*/
|
*/
|
||||||
public function authorize()
|
public function authorize()
|
||||||
{
|
{
|
||||||
return true;
|
return $this->user()->can('create', ENTITY_PAYMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace app\Http\Requests;
|
<?php namespace App\Http\Requests;
|
||||||
|
|
||||||
use App\Http\Requests\Request;
|
use App\Http\Requests\Request;
|
||||||
use Illuminate\Validation\Factory;
|
use Illuminate\Validation\Factory;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace app\Http\Requests;
|
<?php namespace App\Http\Requests;
|
||||||
|
|
||||||
use App\Http\Requests\Request;
|
use App\Http\Requests\Request;
|
||||||
use Illuminate\Validation\Factory;
|
use Illuminate\Validation\Factory;
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
<?php namespace app\Http\Requests;
|
<?php namespace App\Http\Requests;
|
||||||
// vendor
|
|
||||||
use App\Http\Requests\Request;
|
|
||||||
use Illuminate\Validation\Factory;
|
|
||||||
|
|
||||||
class CreateVendorRequest extends Request
|
class CreateVendorRequest extends VendorRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Determine if the user is authorized to make this request.
|
* Determine if the user is authorized to make this request.
|
||||||
@ -12,7 +9,7 @@ class CreateVendorRequest extends Request
|
|||||||
*/
|
*/
|
||||||
public function authorize()
|
public function authorize()
|
||||||
{
|
{
|
||||||
return true;
|
return $this->user()->can('create', ENTITY_VENDOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,7 +4,7 @@ use App\Http\Requests\Request;
|
|||||||
use Input;
|
use Input;
|
||||||
use Utils;
|
use Utils;
|
||||||
|
|
||||||
class BaseRequest extends Request {
|
class EntityRequest extends Request {
|
||||||
|
|
||||||
protected $entityType;
|
protected $entityType;
|
||||||
private $entity;
|
private $entity;
|
||||||
@ -14,7 +14,7 @@ class BaseRequest extends Request {
|
|||||||
if ($this->entity) {
|
if ($this->entity) {
|
||||||
return $this->entity;
|
return $this->entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
$paramName = $this->entityType . 's';
|
$paramName = $this->entityType . 's';
|
||||||
$publicId = $this->$paramName ?: (Input::get('public_id') ?: Input::get('id'));
|
$publicId = $this->$paramName ?: (Input::get('public_id') ?: Input::get('id'));
|
||||||
|
|
||||||
@ -27,4 +27,18 @@ class BaseRequest extends Request {
|
|||||||
|
|
||||||
return $this->entity;
|
return $this->entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
if ($this->entity()) {
|
||||||
|
return $this->user()->can('view', $this->entity());
|
||||||
|
} else {
|
||||||
|
return $this->user()->can('create', $this->entityType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace app\Http\Requests;
|
<?php namespace App\Http\Requests;
|
||||||
|
|
||||||
use Auth;
|
use Auth;
|
||||||
use App\Http\Requests\Request;
|
use App\Http\Requests\Request;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace app\Http\Requests;
|
<?php namespace App\Http\Requests;
|
||||||
|
|
||||||
use Auth;
|
use Auth;
|
||||||
use App\Http\Requests\Request;
|
use App\Http\Requests\Request;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace app\Http\Requests;
|
<?php namespace App\Http\Requests;
|
||||||
|
|
||||||
use App\Http\Requests\Request;
|
use App\Http\Requests\Request;
|
||||||
use Illuminate\Validation\Factory;
|
use Illuminate\Validation\Factory;
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
<?php namespace app\Http\Requests;
|
<?php namespace App\Http\Requests;
|
||||||
|
|
||||||
use App\Http\Requests\Request;
|
class UpdateExpenseRequest extends ExpenseRequest
|
||||||
use Illuminate\Validation\Factory;
|
|
||||||
|
|
||||||
|
|
||||||
class UpdateExpenseRequest extends Request
|
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Determine if the user is authorized to make this request.
|
* Determine if the user is authorized to make this request.
|
||||||
@ -13,7 +9,7 @@ class UpdateExpenseRequest extends Request
|
|||||||
*/
|
*/
|
||||||
public function authorize()
|
public function authorize()
|
||||||
{
|
{
|
||||||
return true;
|
return $this->user()->can('edit', $this->entity());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace app\Http\Requests;
|
<?php namespace App\Http\Requests;
|
||||||
|
|
||||||
use Auth;
|
use Auth;
|
||||||
use App\Http\Requests\Request;
|
use App\Http\Requests\Request;
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
<?php namespace app\Http\Requests;
|
<?php namespace App\Http\Requests;
|
||||||
|
|
||||||
use App\Http\Requests\Request;
|
class UpdatePaymentRequest extends PaymentRequest
|
||||||
use Illuminate\Validation\Factory;
|
|
||||||
|
|
||||||
class UpdatePaymentRequest extends Request
|
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Determine if the user is authorized to make this request.
|
* Determine if the user is authorized to make this request.
|
||||||
@ -12,7 +9,7 @@ class UpdatePaymentRequest extends Request
|
|||||||
*/
|
*/
|
||||||
public function authorize()
|
public function authorize()
|
||||||
{
|
{
|
||||||
return true;
|
return $this->user()->can('edit', $this->entity());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace app\Http\Requests;
|
<?php namespace App\Http\Requests;
|
||||||
|
|
||||||
use App\Http\Requests\Request;
|
use App\Http\Requests\Request;
|
||||||
use Illuminate\Validation\Factory;
|
use Illuminate\Validation\Factory;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace app\Http\Requests;
|
<?php namespace App\Http\Requests;
|
||||||
|
|
||||||
use App\Http\Requests\Request;
|
use App\Http\Requests\Request;
|
||||||
use Illuminate\Validation\Factory;
|
use Illuminate\Validation\Factory;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace app\Http\Requests;
|
<?php namespace App\Http\Requests;
|
||||||
|
|
||||||
use Auth;
|
use Auth;
|
||||||
use App\Http\Requests\Request;
|
use App\Http\Requests\Request;
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
<?php namespace app\Http\Requests;
|
<?php namespace App\Http\Requests;
|
||||||
// vendor
|
|
||||||
use App\Http\Requests\Request;
|
|
||||||
use Illuminate\Validation\Factory;
|
|
||||||
|
|
||||||
class UpdateVendorRequest extends Request
|
class UpdateVendorRequest extends VendorRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Determine if the user is authorized to make this request.
|
* Determine if the user is authorized to make this request.
|
||||||
@ -12,7 +9,7 @@ class UpdateVendorRequest extends Request
|
|||||||
*/
|
*/
|
||||||
public function authorize()
|
public function authorize()
|
||||||
{
|
{
|
||||||
return true;
|
return $this->user()->can('edit', $this->entity());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace app\Listeners;
|
<?php namespace App\Listeners;
|
||||||
|
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Events\ClientWasCreated;
|
use App\Events\ClientWasCreated;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace app\Listeners;
|
<?php namespace App\Listeners;
|
||||||
|
|
||||||
use Carbon;
|
use Carbon;
|
||||||
use App\Models\Credit;
|
use App\Models\Credit;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace app\Listeners;
|
<?php namespace App\Listeners;
|
||||||
|
|
||||||
use Carbon;
|
use Carbon;
|
||||||
use App\Models\Expense;
|
use App\Models\Expense;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace app\Listeners;
|
<?php namespace App\Listeners;
|
||||||
|
|
||||||
use Utils;
|
use Utils;
|
||||||
use Auth;
|
use Auth;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace app\Listeners;
|
<?php namespace App\Listeners;
|
||||||
|
|
||||||
use Utils;
|
use Utils;
|
||||||
use Auth;
|
use Auth;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace app\Listeners;
|
<?php namespace App\Listeners;
|
||||||
|
|
||||||
use App\Ninja\Mailers\UserMailer;
|
use App\Ninja\Mailers\UserMailer;
|
||||||
use App\Ninja\Mailers\ContactMailer;
|
use App\Ninja\Mailers\ContactMailer;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace app\Listeners;
|
<?php namespace App\Listeners;
|
||||||
|
|
||||||
use Carbon;
|
use Carbon;
|
||||||
use App\Events\QuoteWasEmailed;
|
use App\Events\QuoteWasEmailed;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace app\Listeners;
|
<?php namespace App\Listeners;
|
||||||
|
|
||||||
use Auth;
|
use Auth;
|
||||||
use Utils;
|
use Utils;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace app\Listeners;
|
<?php namespace App\Listeners;
|
||||||
|
|
||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
use App\Events\InvoiceWasDeleted;
|
use App\Events\InvoiceWasDeleted;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace app\Models;
|
<?php namespace App\Models;
|
||||||
|
|
||||||
use Eloquent;
|
use Eloquent;
|
||||||
use Auth;
|
use Auth;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace app\Ninja\Repositories;
|
<?php namespace App\Ninja\Repositories;
|
||||||
|
|
||||||
use DB;
|
use DB;
|
||||||
use Utils;
|
use Utils;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace app\Ninja\Repositories;
|
<?php namespace App\Ninja\Repositories;
|
||||||
|
|
||||||
use DB;
|
use DB;
|
||||||
use Utils;
|
use Utils;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace app\Ninja\Repositories;
|
<?php namespace App\Ninja\Repositories;
|
||||||
|
|
||||||
use DB;
|
use DB;
|
||||||
use Utils;
|
use Utils;
|
||||||
|
Loading…
Reference in New Issue
Block a user