在laravel5.5中,如果不使用remember_token登陆,那么,在退出登陆状态时会报错,比如下面是本人程序的报错,
Illuminate \ Database \ QueryException (42S22)
SQLSTATE[42S22]: Column not found: 1054 Unknown column'remember_token' in 'field list' (SQL: update `admin_users` set`remember_token` = OuB1UKZeDasyHUXQCZZ0iMSzKzYUejypth3G35pCgL6WanIAxsYFwQ5p5xH3where `id` = 1)
解决问题的办法也很简单,这个remember_token 是定义在
D:\wamp64\www\laravel\larablog\vendor\laravel\framework\src\Illuminate\Auth\Authenticatable.php
protected $rememberTokenName = 'remember_token';
在你创建的模型中(我这里是User),改写掉这个rememeber_token,返回后程序不会再去数据库中找这一条了。如下,
use Illuminate\Notifications\Notifiable; use Illuminate\Foundation\Auth\User as Authenticatable; class User extends Authenticatable { ... //加上下面这一句,相当于把$rememberTokenName清空, protected $rememberTokenName = ''; .... /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'name', 'password', ]; /** * The attributes that should be hidden for arrays. * * @var array */ // protected $hidden = [ // 'password', 'remember_token', // ]; protected $hidden = [ 'password', ]; }
https://blog.csdn.net/tanmx219/article/details/78816694
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/112910.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...