2017-01-30 20:40:43 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Ninja\Transformers;
|
2016-11-29 18:47:26 +01:00
|
|
|
|
|
|
|
use App\Models\Project;
|
|
|
|
|
2016-12-29 17:17:17 +01:00
|
|
|
/**
|
|
|
|
* @SWG\Definition(definition="Project", @SWG\Xml(name="Project"))
|
|
|
|
*/
|
2016-11-29 18:47:26 +01:00
|
|
|
class ProjectTransformer extends EntityTransformer
|
|
|
|
{
|
2016-12-29 17:17:17 +01:00
|
|
|
/**
|
2017-01-30 20:40:43 +01:00
|
|
|
* @SWG\Property(property="id", type="integer", example=1, readOnly=true)
|
|
|
|
* @SWG\Property(property="name", type="string", example="Sample")
|
|
|
|
* @SWG\Property(property="client_id", type="integer", example=1)
|
2017-03-09 11:11:45 +01:00
|
|
|
* @SWG\Property(property="updated_at", type="integer", example=1451160233, readOnly=true)
|
|
|
|
* @SWG\Property(property="archived_at", type="integer", example=1451160233, readOnly=true)
|
2017-01-30 20:40:43 +01:00
|
|
|
* @SWG\Property(property="is_deleted", type="boolean", example=false, readOnly=true)
|
2017-10-17 12:57:20 +02:00
|
|
|
* @SWG\Property(property="task_rate", type="number", format="float", example=10)
|
2017-01-30 20:40:43 +01:00
|
|
|
*/
|
2016-11-29 18:47:26 +01:00
|
|
|
public function transform(Project $project)
|
|
|
|
{
|
|
|
|
return array_merge($this->getDefaults($project), [
|
|
|
|
'id' => (int) $project->public_id,
|
|
|
|
'name' => $project->name,
|
|
|
|
'client_id' => $project->client ? (int) $project->client->public_id : null,
|
|
|
|
'updated_at' => $this->getTimestamp($project->updated_at),
|
|
|
|
'archived_at' => $this->getTimestamp($project->deleted_at),
|
|
|
|
'is_deleted' => (bool) $project->is_deleted,
|
2017-10-17 12:57:20 +02:00
|
|
|
'task_rate' => (float) $project->task_rate,
|
2016-11-29 18:47:26 +01:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|