<td> <form action={{ route('task.status', [$task]) }} method="POST"> {{ csrf_field() }} <button type="submit">check</button> </form> </td>
This is the button itself.
Route::post('/', ['middleware' => 'auth', 'uses' =>'PostController@check_box'])->name('task.status');
This is the route
public function check_box(Task $task) { dd($task->name); if ($task->is_active == true) { dd($task->is_active); $task->is_active = false; $task->save(); }else{ $task->is_active = true; $task->save(); } return redirect('/'); }
This is the controller itself + I have a model so that the task variable comes out of the database
public function boot() { Route::model("task",Task::class); parent::boot(); }
the button on dd in the controller gives out any request for information id, name, etc. gives out null, tell me what is wrong and if there is an article on this issue I will gladly read it, I haven’t found anything like it