我有一个名为active_user的列以显示用户何时在线(1)。当我登录用户时,我将active_user列设置为1,但是当我登录用户并检查active_user时,它仍然显示在线(1)。我想要的是,当我单击注销按钮时,aactive_user列将更改为脱机(0)并将其更新到数据库。我的登录信息如下。如何在退出时更改laravel中的列的值
public function postSignIn(Request $request) {
$this->validate($request, [
'email' => 'required',
'password' => 'required'
]);
if(Auth::attempt(['email' => $request['email'], 'password' => $request['password']])) {
$user=User::whereRaw('email=?',[Input::get('email')])->first();
//this is where i set the active_user to 1
$user->active_user=1;
$user->save();
if($user!=null){
switch($user->role_id){
case 1:
if($user->status==0){
session()->flash('flash_message_error', ' Your Account has been deactivated. Contact the administrator');
return Redirect::to('admin/login');
}
return redirect()->route("index");
break;
然后下面是注销功能我注销功能
public function LogOut($id) {
$user = User::find($id);
$user->active_user=1;
$user->save();
Auth::logout();
return redirect('admin/login');
}
我想改变active_user回到离线(0),但我不断收到错误“缺少参数1为App \的Http \ Controllers \ AdminController :: LogOut()“
您可以使用登录/注销事件..看看这个公认的答案:http://stackoverflow.com/questions/36767556/laravel-auth-count-user-login/36767937#36767937 –
什么我试图做的是更新active_user返回到离线(0)当我clcik注销按钮 –