mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Add documents to transformers
This commit is contained in:
parent
f5cba4702e
commit
66fe5aa4ee
@ -12,9 +12,11 @@
|
||||
namespace App\Transformers;
|
||||
|
||||
use App\Models\Client;
|
||||
use App\Models\Document;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Payment;
|
||||
use App\Models\Paymentable;
|
||||
use App\Transformers\DocumentTransformer;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
|
||||
class PaymentTransformer extends EntityTransformer
|
||||
@ -29,6 +31,7 @@ class PaymentTransformer extends EntityTransformer
|
||||
'client',
|
||||
'invoices',
|
||||
'paymentables'
|
||||
'documents'
|
||||
];
|
||||
|
||||
public function __construct($serializer = null)
|
||||
@ -59,6 +62,11 @@ class PaymentTransformer extends EntityTransformer
|
||||
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)
|
||||
{
|
||||
|
@ -12,8 +12,10 @@
|
||||
namespace App\Transformers;
|
||||
|
||||
use App\Models\Company;
|
||||
use App\Models\Document;
|
||||
use App\Models\Product;
|
||||
use App\Models\User;
|
||||
use App\Transformers\DocumentTransformer;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
|
||||
class ProductTransformer extends EntityTransformer
|
||||
@ -28,7 +30,8 @@ class ProductTransformer extends EntityTransformer
|
||||
*/
|
||||
protected $availableIncludes = [
|
||||
'company',
|
||||
'user'
|
||||
'user',
|
||||
'documents',
|
||||
];
|
||||
|
||||
|
||||
@ -56,6 +59,12 @@ class ProductTransformer extends EntityTransformer
|
||||
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)
|
||||
{
|
||||
return [
|
||||
|
Loading…
Reference in New Issue
Block a user