I want to delete only checked tasks. At the moment I have this:
<form method="POST" action="/destroy">
@foreach($tasks as $t)
<label>
<input type="checkbox" name="checked[]" value="$t->id">
</label>
@endforeach
<button type="submit">Submit!</button>
</form>
This is my Controller
public function destroy(Request $request)
{
$this->validate($request, [
'checked' => 'required',
]);
$checked = $request->input('checked');
Task::destroy($checked);
}
And this is my route
Route::post('/destroy', [
'uses' => 'Controller@destroy',
]);
I don't get no error but the system does not work
Aucun commentaire:
Enregistrer un commentaire