mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge pull request #8560 from beganovich/projects-client-relationship
Client and tasks includes for project
This commit is contained in:
commit
dace4a4370
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoice Ninja (https://invoiceninja.com).
|
* Invoice Ninja (https://invoiceninja.com).
|
||||||
*
|
*
|
||||||
@ -11,8 +12,10 @@
|
|||||||
|
|
||||||
namespace App\Transformers;
|
namespace App\Transformers;
|
||||||
|
|
||||||
|
use App\Models\Client;
|
||||||
use App\Models\Document;
|
use App\Models\Document;
|
||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
|
use App\Models\Task;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -30,6 +33,8 @@ class ProjectTransformer extends EntityTransformer
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $availableIncludes = [
|
protected $availableIncludes = [
|
||||||
|
'client',
|
||||||
|
'tasks',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function includeDocuments(Project $project)
|
public function includeDocuments(Project $project)
|
||||||
@ -39,6 +44,20 @@ class ProjectTransformer extends EntityTransformer
|
|||||||
return $this->includeCollection($project->documents, $transformer, Document::class);
|
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 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)
|
public function transform(Project $project)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user