我正在 Laravel
应用程序中进行ajax登录 . 它在我的本地环境中运行良好,但我将网站移至Production,登录后我看到了这个例外
User.php第29行中的ErrorException:Illuminate \ Foundation \ Auth \ User和Illuminate \ Auth \ Authenticatable在App \ User的组合中定义相同的属性($ rememberTokenName) . 这可能是不兼容的,为了提高可维护性,请考虑在特征中使用访问器方法 . 上课是由
我的用户模型是
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable, \Illuminate\Auth\Authenticatable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password', 'first_name', 'last_name', 'hospital_id', 'census_id', 'employee_id'
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
}
1 回答
Illuminate\Foundation\Auth\User
已经使用了Illuminate\Contracts\Auth\Authenticatable
,所以你基本上应用了两次导致该错误的特征 .这是Illuminate \ Foundation \ Auth \ User.php的代码
另外一个侧面建议可能会将您的别名位
as Authenticable
重命名为AuthUser
/BaseUser
更明确的内容,因此很明显您正在扩展User类 .