2017-01-30 21:40:43 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Ninja\Transformers;
|
2016-11-29 19:47:26 +02:00
|
|
|
|
|
|
|
|
use App\Models\Project;
|
|
|
|
|
|
2016-12-29 18:17:17 +02:00
|
|
|
/**
|
|
|
|
|
* @SWG\Definition(definition="Project", @SWG\Xml(name="Project"))
|
|
|
|
|
*/
|
2016-11-29 19:47:26 +02:00
|
|
|
class ProjectTransformer extends EntityTransformer
|
|
|
|
|
{
|
2016-12-29 18:17:17 +02:00
|
|
|
/**
|
2017-01-30 21:40:43 +02: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 21:40:43 +02:00
|
|
|
* @SWG\Property(property="is_deleted", type="boolean", example=false, readOnly=true)
|
2017-10-17 13:57:20 +03:00
|
|
|
* @SWG\Property(property="task_rate", type="number", format="float", example=10)
|
2018-02-20 21:31:16 +11:00
|
|
|
* @SWG\Property(property="due_date", type="string", format="date", example="2016-01-01")
|
|
|
|
|
* @SWG\Property(property="private_notes", type="string", format="Sample notes", example=10)
|
|
|
|
|
* @SWG\Property(property="budgeted_hours", type="number", format="float", example=10)
|
2019-01-30 22:00:26 +11:00
|
|
|
* @SWG\Property(property="custom_value1", type="string", example="Custom Value")
|
|
|
|
|
* @SWG\Property(property="custom_value2", type="string", example="Custom Value")
|
2017-01-30 21:40:43 +02:00
|
|
|
*/
|
2016-11-29 19:47:26 +02:00
|
|
|
public function transform(Project $project)
|
|
|
|
|
{
|
|
|
|
|
return array_merge($this->getDefaults($project), [
|
|
|
|
|
'id' => (int) $project->public_id,
|
2018-06-26 17:18:32 +05:30
|
|
|
'name' => $project->name ?: '',
|
|
|
|
|
'client_id' => $project->client ? (int) $project->client->public_id : 0,
|
2016-11-29 19:47:26 +02:00
|
|
|
'updated_at' => $this->getTimestamp($project->updated_at),
|
|
|
|
|
'archived_at' => $this->getTimestamp($project->deleted_at),
|
|
|
|
|
'is_deleted' => (bool) $project->is_deleted,
|
2017-10-17 13:57:20 +03:00
|
|
|
'task_rate' => (float) $project->task_rate,
|
2018-06-26 17:18:32 +05:30
|
|
|
'due_date' => $project->due_date ?: '',
|
|
|
|
|
'private_notes' => $project->private_notes ?: '',
|
2018-02-20 21:31:16 +11:00
|
|
|
'budgeted_hours' => (float) $project->budgeted_hours,
|
2018-06-26 17:18:32 +05:30
|
|
|
'custom_value1' => $project->custom_value1 ?: '',
|
|
|
|
|
'custom_value2' => $project->custom_value2 ?: '',
|
2016-11-29 19:47:26 +02:00
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|