diff --git a/app/Http/Requests/EntityRequest.php b/app/Http/Requests/EntityRequest.php index 8679d3ca4195..87a877e4eae3 100644 --- a/app/Http/Requests/EntityRequest.php +++ b/app/Http/Requests/EntityRequest.php @@ -9,7 +9,7 @@ class EntityRequest extends Request { protected $entityType; private $entity; - public function entity() + public function entity() { if ($this->entity) { return $this->entity; @@ -20,24 +20,24 @@ class EntityRequest extends Request { foreach (['_id', 's'] as $suffix) { $field = $this->entityType . $suffix; if ($this->$field) { - $publicId= $this->$field; - } + $publicId= $this->$field; + } } if ( ! $publicId) { $publicId = Input::get('public_id') ?: Input::get('id'); } if ( ! $publicId) { return null; - } - + } + $class = Utils::getEntityClass($this->entityType); - + \Log::info('entity ' . $this->entityType . ' - ' . $publicId); if (method_exists($class, 'withTrashed')) { $this->entity = $class::scope($publicId)->withTrashed()->firstOrFail(); } else { $this->entity = $class::scope($publicId)->firstOrFail(); } - + \Log::info($this->entity); return $this->entity; } diff --git a/app/Http/Requests/InvoiceRequest.php b/app/Http/Requests/InvoiceRequest.php index 88366937e91f..edf43203c695 100644 --- a/app/Http/Requests/InvoiceRequest.php +++ b/app/Http/Requests/InvoiceRequest.php @@ -10,7 +10,6 @@ class InvoiceRequest extends EntityRequest { { $invoice = parent::entity(); - /* // support loading an invoice by its invoice number if ($this->invoice_number && ! $invoice) { $invoice = Invoice::scope() @@ -18,8 +17,7 @@ class InvoiceRequest extends EntityRequest { ->withTrashed() ->firstOrFail(); } - */ - + // eager load the invoice items if ($invoice && ! $invoice->relationLoaded('invoice_items')) { $invoice->load('invoice_items');