【发布时间】:2016-03-21 19:19:14
【问题描述】:
我在我的 Laravel 项目中使用了php artisan make:auth 命令,这就是我未更改的App\Models\User.php 的样子:
<?php
namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];}
现在,根据 Entrusts 文档,我应该将 User.php 文件更改为以下内容:
<?php
use Zizaco\Entrust\Traits\EntrustUserTrait;
class User extends Eloquent
{
use EntrustUserTrait; // add this trait to your user model
...
}
我想使用 Laravel 内置的身份验证系统和 Entrust 用户角色。我怎样才能将这两者混合在一起工作?正如我所读到的,不可能使用多个扩展。有什么简单的解决方案?
【问题讨论】:
标签: php class laravel laravel-5.2 entrust