mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge pull request #7612 from beganovich/tasks-client-relationship
`Client` include in TaskTransformer
This commit is contained in:
commit
6e723e4b24
@ -14,6 +14,7 @@ namespace App\Transformers;
|
||||
use App\Models\Document;
|
||||
use App\Models\Task;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use League\Fractal\Resource\Item;
|
||||
|
||||
/**
|
||||
* class TaskTransformer.
|
||||
@ -30,6 +31,7 @@ class TaskTransformer extends EntityTransformer
|
||||
* @var array
|
||||
*/
|
||||
protected $availableIncludes = [
|
||||
'client',
|
||||
];
|
||||
|
||||
public function includeDocuments(Task $task)
|
||||
@ -39,6 +41,13 @@ class TaskTransformer extends EntityTransformer
|
||||
return $this->includeCollection($task->documents, $transformer, Document::class);
|
||||
}
|
||||
|
||||
public function includeClient(Task $task): Item
|
||||
{
|
||||
$transformer = new ClientTransformer($this->serializer);
|
||||
|
||||
return $this->includeItem($task->client, $transformer, Client::class);
|
||||
}
|
||||
|
||||
public function transform(Task $task)
|
||||
{
|
||||
return [
|
||||
|
Loading…
x
Reference in New Issue
Block a user