front toDos almost position, checked, delete

This commit is contained in:
2020-05-02 10:27:47 +02:00
parent 6d29dbc9bd
commit 2c0536a864
7 changed files with 161 additions and 158 deletions

View File

@@ -59,6 +59,18 @@ class ToDoController extends Controller
->setStatusCode(200);
}
public function checkedToogle(ToDoList $toDoList, ToDo $toDo)
{
$this->authorize('update', $toDoList);
($toDo->checked_at) ? $toDo->checked_at = NULL : $toDo->checked_at = now();
$toDo->save();
return (new ToDoResource($toDo))
->response()
->setStatusCode(200);
}
private function validateData()
{
return request()->validate([

View File

@@ -22,7 +22,7 @@ class ToDo extends JsonResource
'data' => [
'name' => $this->name,
'order' => (int) $this->order,
'checked_at' => optional($this->checked_at)->diffForHumans(),
'checked_at' => ($this->checked_at) ? 1 : null,
'last_updated' => $this->updated_at->diffForHumans(),
]
]