当我在laravel中提交表单时,用户会话过期,并且注销了当前用户。我以为是csrf令牌问题,所以我禁用了它的验证功能,但问题仍然存在。
我的观点
<form action="{{url('/save-user-details')}}" method="POST" enctype="multipart/form-data"
>
@csrf
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Primeiro Name</label>
<input type="text" class="form-control"
name="firstName" required>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Apelido</label>
<input type="text" class="form-control" name="lastName" required>
</div>
</div>
</div>
<button type="submit" class="button pull-right" value="">Actualizar Perfil</button>
</form>
我的路线列表
Route::post('/save-user-details', 'DashboardController@saveUser');
Route::get('/editar-usuario', 'DashboardController@editProfile');
我的控制器
public function __construct()
{
$this->middleware('auth');
}
public function saveUser(Request $request){
$user_id = auth()->user()->id;
$user = User::find($user_id);
$detalhes = new Detalhesuser;
$detalhes->user_id = $user_id;
$detalhes->firstName = $request->input('firstName');
$detalhes->lastName = $request->input('lastName');
$detalhes->profissao = $request->input('profissao');
$detalhes->instituicao = $request->input('instituicao');
$detalhes->biografia = $request->input('biografia');
$detalhes->save();
$user->detalhesUser_id = $detalhes->id;
$user->save();
return redirect('/dashboard')->with('success', 'Detalhes salvos');
}
我的会话存储在文件中。我试图将其更改为数据库,问题仍然存在。
知道我在哪里做错了吗?