7e367d67da
* Tasks are now edited inline * Tasks can be marked as completed * Tasks can be edited
34 lines
1.1 KiB
PHP
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'))),
|
|
];
|
|
}
|
|
}
|