This is the first part of the API. It supports most of contacts, as well as the journal. This PR also brings Monica to Laravel 5.5, as the API required it with the new concept of resources. It needs to run `php artisan migrate` as well as `php artisan passport:keys` to generate the access tokens needed for the API.
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,
|
|
'status' => $this->status,
|
|
'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'))),
|
|
];
|
|
}
|
|
}
|