Client include for projects

This commit is contained in:
Benjamin Beganović 2023-06-15 14:33:48 +02:00
parent d2f54bb11b
commit 781ecb34fc

View File

@ -1,4 +1,5 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
@ -11,6 +12,7 @@
namespace App\Transformers;
use App\Models\Client;
use App\Models\Document;
use App\Models\Project;
use App\Utils\Traits\MakesHash;
@ -30,6 +32,7 @@ class ProjectTransformer extends EntityTransformer
* @var array
*/
protected $availableIncludes = [
'client',
];
public function includeDocuments(Project $project)
@ -39,6 +42,13 @@ class ProjectTransformer extends EntityTransformer
return $this->includeCollection($project->documents, $transformer, Document::class);
}
public function includeClient(Project $project): \League\Fractal\Resource\Item
{
$transformer = new ClientTransformer($this->serializer);
return $this->includeItem($project->client, $transformer, Client::class);
}
public function transform(Project $project)
{
return [