Атрибут href
<a>
внутри <button>
имеет приоритет над атрибутом <form>
action
, поэтому ваше действие обновления никогда не вызывается.Вы должны выполнить перенаправление в вашем действии маршрута, например, контроллер:
class UserController extends Controller
{
// other actions
public function update(Request $request, $id)
{
$user = User::find($id);
$user->fill($request->all()); // Do not fill unvalidated data
if (!$user->save()) {
// Handle error
// Redirect to the edit form while preserving the input
return redirect()->back()->withInput();
}
// Redirect to the 'show' page on success
return redirect()->route('users.show', ['id' => $user->id]);
}
// more actions
}
Ваша форма должна выглядеть примерно так:
<form action="{{ route('user.update', ['id' => $user->id]) }}" method="POST">
<!-- Use @method and @csrf depending on your route's HTTP verb and if you have CSRF protection enabled -->
@method('PUT')
@csrf
<!-- Your form fields -->
<button type="submit" class="btn btn-outline-success btn-block">
Valider la modification
</button>
</form>