Refactored controller->entity to entityType

This commit is contained in:
Hillel Coren 2016-04-28 13:53:29 +03:00
parent ce2392563d
commit 882cfb79fd
10 changed files with 14 additions and 14 deletions

View File

@ -10,7 +10,7 @@ class BaseController extends Controller
{
use DispatchesJobs, AuthorizesRequests;
protected $entity;
protected $entityType;
/**
* Setup the layout used by the controller.
@ -25,17 +25,17 @@ class BaseController extends Controller
}
protected function authorizeCreate() {
$this->authorize('create', $this->entity);
$this->authorize('create', $this->entityType);
}
protected function authorizeUpdate($input){
$creating = empty($input['public_id']) || $input['public_id'] == '-1';
if($creating){
$this->authorize('create', $this->entity);
$this->authorize('create', $this->entityType);
}
else{
$className = Utils::getEntityName($this->entity);
$className = Utils::getEntityName($this->entityType);
$object = call_user_func(array("App\\Models\\{$className}", 'scope'), $input['public_id'])->firstOrFail();
$this->authorize('edit', $object);

View File

@ -35,7 +35,7 @@ class ClientController extends BaseController
{
protected $clientService;
protected $clientRepo;
protected $entity = ENTITY_CLIENT;
protected $entityType = ENTITY_CLIENT;
public function __construct(ClientRepository $clientRepo, ClientService $clientService)
{

View File

@ -17,7 +17,7 @@ class CreditController extends BaseController
{
protected $creditRepo;
protected $creditService;
protected $entity = ENTITY_CREDIT;
protected $entityType = ENTITY_CREDIT;
public function __construct(CreditRepository $creditRepo, CreditService $creditService)
{

View File

@ -15,7 +15,7 @@ use App\Ninja\Repositories\DocumentRepository;
class DocumentController extends BaseController
{
protected $documentRepo;
protected $entity = ENTITY_DOCUMENT;
protected $entityType = ENTITY_DOCUMENT;
public function __construct(DocumentRepository $documentRepo)
{

View File

@ -25,7 +25,7 @@ class ExpenseController extends BaseController
// Expenses
protected $expenseRepo;
protected $expenseService;
protected $entity = ENTITY_EXPENSE;
protected $entityType = ENTITY_EXPENSE;
public function __construct(ExpenseRepository $expenseRepo, ExpenseService $expenseService)
{

View File

@ -37,7 +37,7 @@ class InvoiceController extends BaseController
protected $documentRepo;
protected $invoiceService;
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)
{

View File

@ -30,7 +30,7 @@ use App\Http\Requests\UpdatePaymentRequest;
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)
{

View File

@ -33,7 +33,7 @@ class QuoteController extends BaseController
protected $invoiceRepo;
protected $clientRepo;
protected $invoiceService;
protected $entity = ENTITY_INVOICE;
protected $entityType = ENTITY_INVOICE;
public function __construct(Mailer $mailer, InvoiceRepository $invoiceRepo, ClientRepository $clientRepo, InvoiceService $invoiceService)
{

View File

@ -22,7 +22,7 @@ class TaskController extends BaseController
{
protected $taskRepo;
protected $taskService;
protected $entity = ENTITY_TASK;
protected $entityType = ENTITY_TASK;
public function __construct(TaskRepository $taskRepo, InvoiceRepository $invoiceRepo, TaskService $taskService)
{

View File

@ -25,12 +25,12 @@ use App\Services\VendorService;
use App\Http\Requests\CreateVendorRequest;
use App\Http\Requests\UpdateVendorRequest;
// vendor
class VendorController extends BaseController
{
protected $vendorService;
protected $vendorRepo;
protected $entity = ENTITY_VENDOR;
protected $entityType = ENTITY_VENDOR;
public function __construct(VendorRepository $vendorRepo, VendorService $vendorService)
{