Files
monica/app/Http/Resources/Note/Note.php
T
Régis FreydandGitHub 76c75ce6e7 Add inline notes editing and favorites for notes (#672)
Notes are now edited inline (with Vue.js) and can be marked as favorites.
Favorite notes will appear on the dashboard in a new tab.
2017-12-04 09:55:47 -05:00

33 lines
1.0 KiB
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,
'is_favorited' => (bool) $this->is_favorited,
'favorited_at' => (is_null($this->favorited_at) ? null : $this->favorited_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'))),
];
}
}