7e1cd96bf5
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.
31 lines
859 B
PHP
31 lines
859 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources\Note;
|
|
|
|
use Illuminate\Http\Resources\Json\Resource;
|
|
use App\Http\Resources\Contact\ContactShort as ContactShortResource;
|
|
|
|
class Note extends Resource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request
|
|
* @return array
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'object' => 'note',
|
|
'body' => $this->body,
|
|
'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'))),
|
|
];
|
|
}
|
|
}
|