36 lines
937 B
PHP
36 lines
937 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class ToDo extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
return [
|
|
'data' => [
|
|
'type' => 'to-dos',
|
|
'to_do_id' => $this->id,
|
|
'attributes' => [
|
|
'data' => [
|
|
'name' => $this->name,
|
|
'order' => (int) $this->order,
|
|
'checked_at' => optional($this->checked_at)->diffForHumans(),
|
|
'last_updated' => $this->updated_at->diffForHumans(),
|
|
]
|
|
]
|
|
],
|
|
'links' => [
|
|
'self' => url('/to-do-lists/'.$this->to_do_list_id),
|
|
]
|
|
];
|
|
}
|
|
}
|