diff --git a/app/Transformers/ProjectTransformer.php b/app/Transformers/ProjectTransformer.php index 477a89dbd4..96c67311f8 100644 --- a/app/Transformers/ProjectTransformer.php +++ b/app/Transformers/ProjectTransformer.php @@ -15,6 +15,7 @@ namespace App\Transformers; use App\Models\Client; use App\Models\Document; use App\Models\Project; +use App\Models\Task; use App\Utils\Traits\MakesHash; /** @@ -33,6 +34,7 @@ class ProjectTransformer extends EntityTransformer */ protected $availableIncludes = [ 'client', + 'tasks', ]; public function includeDocuments(Project $project) @@ -49,6 +51,13 @@ class ProjectTransformer extends EntityTransformer return $this->includeItem($project->client, $transformer, Client::class); } + public function includeTasks(Project $project): \League\Fractal\Resource\Collection + { + $transformer = new TaskTransformer($this->serializer); + + return $this->includeCollection($project->tasks, $transformer, Task::class); + } + public function transform(Project $project) { return [