mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Working on tests
This commit is contained in:
parent
cc55cdc1b5
commit
be11054b31
@ -9,7 +9,7 @@ class EntityRequest extends Request {
|
|||||||
protected $entityType;
|
protected $entityType;
|
||||||
private $entity;
|
private $entity;
|
||||||
|
|
||||||
public function entity()
|
public function entity()
|
||||||
{
|
{
|
||||||
if ($this->entity) {
|
if ($this->entity) {
|
||||||
return $this->entity;
|
return $this->entity;
|
||||||
@ -20,24 +20,24 @@ class EntityRequest extends Request {
|
|||||||
foreach (['_id', 's'] as $suffix) {
|
foreach (['_id', 's'] as $suffix) {
|
||||||
$field = $this->entityType . $suffix;
|
$field = $this->entityType . $suffix;
|
||||||
if ($this->$field) {
|
if ($this->$field) {
|
||||||
$publicId= $this->$field;
|
$publicId= $this->$field;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( ! $publicId) {
|
if ( ! $publicId) {
|
||||||
$publicId = Input::get('public_id') ?: Input::get('id');
|
$publicId = Input::get('public_id') ?: Input::get('id');
|
||||||
}
|
}
|
||||||
if ( ! $publicId) {
|
if ( ! $publicId) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$class = Utils::getEntityClass($this->entityType);
|
$class = Utils::getEntityClass($this->entityType);
|
||||||
|
\Log::info('entity ' . $this->entityType . ' - ' . $publicId);
|
||||||
if (method_exists($class, 'withTrashed')) {
|
if (method_exists($class, 'withTrashed')) {
|
||||||
$this->entity = $class::scope($publicId)->withTrashed()->firstOrFail();
|
$this->entity = $class::scope($publicId)->withTrashed()->firstOrFail();
|
||||||
} else {
|
} else {
|
||||||
$this->entity = $class::scope($publicId)->firstOrFail();
|
$this->entity = $class::scope($publicId)->firstOrFail();
|
||||||
}
|
}
|
||||||
|
\Log::info($this->entity);
|
||||||
return $this->entity;
|
return $this->entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ class InvoiceRequest extends EntityRequest {
|
|||||||
{
|
{
|
||||||
$invoice = parent::entity();
|
$invoice = parent::entity();
|
||||||
|
|
||||||
/*
|
|
||||||
// support loading an invoice by its invoice number
|
// support loading an invoice by its invoice number
|
||||||
if ($this->invoice_number && ! $invoice) {
|
if ($this->invoice_number && ! $invoice) {
|
||||||
$invoice = Invoice::scope()
|
$invoice = Invoice::scope()
|
||||||
@ -18,8 +17,7 @@ class InvoiceRequest extends EntityRequest {
|
|||||||
->withTrashed()
|
->withTrashed()
|
||||||
->firstOrFail();
|
->firstOrFail();
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
// eager load the invoice items
|
// eager load the invoice items
|
||||||
if ($invoice && ! $invoice->relationLoaded('invoice_items')) {
|
if ($invoice && ! $invoice->relationLoaded('invoice_items')) {
|
||||||
$invoice->load('invoice_items');
|
$invoice->load('invoice_items');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user