first work on To Do Lists

This commit is contained in:
2020-04-19 22:46:28 +02:00
parent c71f3ca4d8
commit c6b94aa1f1
17 changed files with 710 additions and 2 deletions

View File

@@ -0,0 +1,38 @@
<?php
namespace App\Http\Resources;
use App\Http\Resources\User as UserResource;
use Illuminate\Http\Resources\Json\JsonResource;
class ToDoList extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'data' => [
'type' => 'to-do-lists',
'to_do_list_id' => $this->id,
'attributes' => [
'data' => [
'name' => $this->name,
'to_dos' => new ToDoCollection($this->toDos),
'posted_by' => new UserResource($this->user),
'last_updated' => $this->updated_at->diffForHumans(),
// 'cover_image' => new ImageResource($this->coverImage),
]
]
//'tags' => TagResource::collection($this->tags),
],
'links' => [
'self' => $this->path(),
]
];
}
}