mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Refactored controller->entity to entityType
This commit is contained in:
parent
ce2392563d
commit
882cfb79fd
@ -10,7 +10,7 @@ class BaseController extends Controller
|
|||||||
{
|
{
|
||||||
use DispatchesJobs, AuthorizesRequests;
|
use DispatchesJobs, AuthorizesRequests;
|
||||||
|
|
||||||
protected $entity;
|
protected $entityType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup the layout used by the controller.
|
* Setup the layout used by the controller.
|
||||||
@ -25,17 +25,17 @@ class BaseController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function authorizeCreate() {
|
protected function authorizeCreate() {
|
||||||
$this->authorize('create', $this->entity);
|
$this->authorize('create', $this->entityType);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function authorizeUpdate($input){
|
protected function authorizeUpdate($input){
|
||||||
$creating = empty($input['public_id']) || $input['public_id'] == '-1';
|
$creating = empty($input['public_id']) || $input['public_id'] == '-1';
|
||||||
|
|
||||||
if($creating){
|
if($creating){
|
||||||
$this->authorize('create', $this->entity);
|
$this->authorize('create', $this->entityType);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$className = Utils::getEntityName($this->entity);
|
$className = Utils::getEntityName($this->entityType);
|
||||||
|
|
||||||
$object = call_user_func(array("App\\Models\\{$className}", 'scope'), $input['public_id'])->firstOrFail();
|
$object = call_user_func(array("App\\Models\\{$className}", 'scope'), $input['public_id'])->firstOrFail();
|
||||||
$this->authorize('edit', $object);
|
$this->authorize('edit', $object);
|
||||||
|
@ -35,7 +35,7 @@ class ClientController extends BaseController
|
|||||||
{
|
{
|
||||||
protected $clientService;
|
protected $clientService;
|
||||||
protected $clientRepo;
|
protected $clientRepo;
|
||||||
protected $entity = ENTITY_CLIENT;
|
protected $entityType = ENTITY_CLIENT;
|
||||||
|
|
||||||
public function __construct(ClientRepository $clientRepo, ClientService $clientService)
|
public function __construct(ClientRepository $clientRepo, ClientService $clientService)
|
||||||
{
|
{
|
||||||
|
@ -17,7 +17,7 @@ class CreditController extends BaseController
|
|||||||
{
|
{
|
||||||
protected $creditRepo;
|
protected $creditRepo;
|
||||||
protected $creditService;
|
protected $creditService;
|
||||||
protected $entity = ENTITY_CREDIT;
|
protected $entityType = ENTITY_CREDIT;
|
||||||
|
|
||||||
public function __construct(CreditRepository $creditRepo, CreditService $creditService)
|
public function __construct(CreditRepository $creditRepo, CreditService $creditService)
|
||||||
{
|
{
|
||||||
|
@ -15,7 +15,7 @@ use App\Ninja\Repositories\DocumentRepository;
|
|||||||
class DocumentController extends BaseController
|
class DocumentController extends BaseController
|
||||||
{
|
{
|
||||||
protected $documentRepo;
|
protected $documentRepo;
|
||||||
protected $entity = ENTITY_DOCUMENT;
|
protected $entityType = ENTITY_DOCUMENT;
|
||||||
|
|
||||||
public function __construct(DocumentRepository $documentRepo)
|
public function __construct(DocumentRepository $documentRepo)
|
||||||
{
|
{
|
||||||
|
@ -25,7 +25,7 @@ class ExpenseController extends BaseController
|
|||||||
// Expenses
|
// Expenses
|
||||||
protected $expenseRepo;
|
protected $expenseRepo;
|
||||||
protected $expenseService;
|
protected $expenseService;
|
||||||
protected $entity = ENTITY_EXPENSE;
|
protected $entityType = ENTITY_EXPENSE;
|
||||||
|
|
||||||
public function __construct(ExpenseRepository $expenseRepo, ExpenseService $expenseService)
|
public function __construct(ExpenseRepository $expenseRepo, ExpenseService $expenseService)
|
||||||
{
|
{
|
||||||
|
@ -37,7 +37,7 @@ class InvoiceController extends BaseController
|
|||||||
protected $documentRepo;
|
protected $documentRepo;
|
||||||
protected $invoiceService;
|
protected $invoiceService;
|
||||||
protected $recurringInvoiceService;
|
protected $recurringInvoiceService;
|
||||||
protected $entity = ENTITY_INVOICE;
|
protected $entityType = ENTITY_INVOICE;
|
||||||
|
|
||||||
public function __construct(Mailer $mailer, InvoiceRepository $invoiceRepo, ClientRepository $clientRepo, InvoiceService $invoiceService, DocumentRepository $documentRepo, RecurringInvoiceService $recurringInvoiceService)
|
public function __construct(Mailer $mailer, InvoiceRepository $invoiceRepo, ClientRepository $clientRepo, InvoiceService $invoiceService, DocumentRepository $documentRepo, RecurringInvoiceService $recurringInvoiceService)
|
||||||
{
|
{
|
||||||
|
@ -30,7 +30,7 @@ use App\Http\Requests\UpdatePaymentRequest;
|
|||||||
|
|
||||||
class PaymentController extends BaseController
|
class PaymentController extends BaseController
|
||||||
{
|
{
|
||||||
protected $entity = ENTITY_PAYMENT;
|
protected $entityType = ENTITY_PAYMENT;
|
||||||
|
|
||||||
public function __construct(PaymentRepository $paymentRepo, InvoiceRepository $invoiceRepo, AccountRepository $accountRepo, ContactMailer $contactMailer, PaymentService $paymentService)
|
public function __construct(PaymentRepository $paymentRepo, InvoiceRepository $invoiceRepo, AccountRepository $accountRepo, ContactMailer $contactMailer, PaymentService $paymentService)
|
||||||
{
|
{
|
||||||
|
@ -33,7 +33,7 @@ class QuoteController extends BaseController
|
|||||||
protected $invoiceRepo;
|
protected $invoiceRepo;
|
||||||
protected $clientRepo;
|
protected $clientRepo;
|
||||||
protected $invoiceService;
|
protected $invoiceService;
|
||||||
protected $entity = ENTITY_INVOICE;
|
protected $entityType = ENTITY_INVOICE;
|
||||||
|
|
||||||
public function __construct(Mailer $mailer, InvoiceRepository $invoiceRepo, ClientRepository $clientRepo, InvoiceService $invoiceService)
|
public function __construct(Mailer $mailer, InvoiceRepository $invoiceRepo, ClientRepository $clientRepo, InvoiceService $invoiceService)
|
||||||
{
|
{
|
||||||
|
@ -22,7 +22,7 @@ class TaskController extends BaseController
|
|||||||
{
|
{
|
||||||
protected $taskRepo;
|
protected $taskRepo;
|
||||||
protected $taskService;
|
protected $taskService;
|
||||||
protected $entity = ENTITY_TASK;
|
protected $entityType = ENTITY_TASK;
|
||||||
|
|
||||||
public function __construct(TaskRepository $taskRepo, InvoiceRepository $invoiceRepo, TaskService $taskService)
|
public function __construct(TaskRepository $taskRepo, InvoiceRepository $invoiceRepo, TaskService $taskService)
|
||||||
{
|
{
|
||||||
|
@ -25,12 +25,12 @@ use App\Services\VendorService;
|
|||||||
|
|
||||||
use App\Http\Requests\CreateVendorRequest;
|
use App\Http\Requests\CreateVendorRequest;
|
||||||
use App\Http\Requests\UpdateVendorRequest;
|
use App\Http\Requests\UpdateVendorRequest;
|
||||||
// vendor
|
|
||||||
class VendorController extends BaseController
|
class VendorController extends BaseController
|
||||||
{
|
{
|
||||||
protected $vendorService;
|
protected $vendorService;
|
||||||
protected $vendorRepo;
|
protected $vendorRepo;
|
||||||
protected $entity = ENTITY_VENDOR;
|
protected $entityType = ENTITY_VENDOR;
|
||||||
|
|
||||||
public function __construct(VendorRepository $vendorRepo, VendorService $vendorService)
|
public function __construct(VendorRepository $vendorRepo, VendorService $vendorService)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user