i added a CRUD interface for my users table and instead of delete button i put a block button which blocks a user (sets bloque field in database from 0 to 1), i added a new function in my controller called block which is supposed to do the job yet i get a MethodNotAllowedHttpException error everytime i click the blocking button
this is the block method in UserController:
public function block($id){
$user = User::find($id);
$user->bloque = 1;
$user->save();
return redirect('/users')->with('success', 'Utilisateur bloqué');
}
this is the blocking html fragment:
<form action="" method="get">
@csrf
<!-- @method('DELETE')-->
<button class="btn btn-danger" type="submit">Bloquer</button>
</form>
this is my web.php (routes):
Route::get('/block', [
'uses' => 'UserController@block',
'as' => 'users.block'
]);
Thanks in advance
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire