This is my controller where i want to know what is correct.
public function complete($id)
{
$task = Task::find($id);
if($task->done_at = '' or $task->done_at = null) {
$task->done_at = date( 'Y-m-d H:i:s', strtotime( 'now' ) );
$task->save();
} elseif ($task->done_at !== null) {
$task->done_at = null;
$task->save();
}
return redirect()->route('tasks.index')->withSuccess('Done');
}
and this is my index page where there is form for clicking
<form action="" method="post">
@csrf
<button type="submit" name="submit"><p style="border-radius: 50%; color:red"></p></button>
</form>
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire