mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Add documents to transformers
This commit is contained in:
parent
f5cba4702e
commit
66fe5aa4ee
@ -12,9 +12,11 @@
|
|||||||
namespace App\Transformers;
|
namespace App\Transformers;
|
||||||
|
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
|
use App\Models\Document;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use App\Models\Paymentable;
|
use App\Models\Paymentable;
|
||||||
|
use App\Transformers\DocumentTransformer;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
|
|
||||||
class PaymentTransformer extends EntityTransformer
|
class PaymentTransformer extends EntityTransformer
|
||||||
@ -29,6 +31,7 @@ class PaymentTransformer extends EntityTransformer
|
|||||||
'client',
|
'client',
|
||||||
'invoices',
|
'invoices',
|
||||||
'paymentables'
|
'paymentables'
|
||||||
|
'documents'
|
||||||
];
|
];
|
||||||
|
|
||||||
public function __construct($serializer = null)
|
public function __construct($serializer = null)
|
||||||
@ -59,6 +62,11 @@ class PaymentTransformer extends EntityTransformer
|
|||||||
return $this->includeCollection($payment->paymentables, $transformer, Paymentable::class);
|
return $this->includeCollection($payment->paymentables, $transformer, Paymentable::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function includeDocuments(Payment $payment)
|
||||||
|
{
|
||||||
|
$transformer = new DocumentTransformer($this->serializer);
|
||||||
|
return $this->includeCollection($payment->documents, $transformer, Document::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function transform(Payment $payment)
|
public function transform(Payment $payment)
|
||||||
{
|
{
|
||||||
|
@ -12,8 +12,10 @@
|
|||||||
namespace App\Transformers;
|
namespace App\Transformers;
|
||||||
|
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
|
use App\Models\Document;
|
||||||
use App\Models\Product;
|
use App\Models\Product;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use App\Transformers\DocumentTransformer;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
|
|
||||||
class ProductTransformer extends EntityTransformer
|
class ProductTransformer extends EntityTransformer
|
||||||
@ -28,7 +30,8 @@ class ProductTransformer extends EntityTransformer
|
|||||||
*/
|
*/
|
||||||
protected $availableIncludes = [
|
protected $availableIncludes = [
|
||||||
'company',
|
'company',
|
||||||
'user'
|
'user',
|
||||||
|
'documents',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
@ -56,6 +59,12 @@ class ProductTransformer extends EntityTransformer
|
|||||||
return $this->includeItem($product->company, $transformer, Company::class);
|
return $this->includeItem($product->company, $transformer, Company::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function includeDocuments(Product $product)
|
||||||
|
{
|
||||||
|
$transformer = new DocumentTransformer($this->serializer);
|
||||||
|
return $this->includeCollection($product->documents, $transformer, Document::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function transform(Product $product)
|
public function transform(Product $product)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user