front toDos almost position, checked, delete
This commit is contained in:
@@ -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([
|
||||
|
||||
@@ -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(),
|
||||
]
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user