Files
monica/app/Http/Resources/Task/Task.php
T
Régis Freyd 7e367d67da Manage tasks in Vue.js (#666)
* Tasks are now edited inline
* Tasks can be marked as completed
* Tasks can be edited
2017-11-29 16:07:37 -05:00

34 lines
1.1 KiB
PHP

<?php
namespace App\Http\Resources\Task;
use Illuminate\Http\Resources\Json\Resource;
use App\Http\Resources\Contact\ContactShort as ContactShortResource;
class Task extends Resource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'object' => 'task',
'title' => $this->title,
'description' => $this->description,
'completed' => (bool) $this->completed,
'completed_at' => (is_null($this->completed_at) ? null : $this->completed_at->format(config('api.timestamp_format'))),
'account' => [
'id' => $this->account->id,
],
'contact' => new ContactShortResource($this->contact),
'created_at' => $this->created_at->format(config('api.timestamp_format')),
'updated_at' => (is_null($this->updated_at) ? null : $this->updated_at->format(config('api.timestamp_format'))),
];
}
}