2016-03-21 46 views
1

我在Laravel项目中使用php artisan make:auth命令,这是多么我不变App\Models\User.php的样子:使用委托具有Laravel内置的身份验证系统

<?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', 
];} 

现在,根据委托文件我应该改变User.php文件如下:

<?php 

use Zizaco\Entrust\Traits\EntrustUserTrait; 

class User extends Eloquent 
{ 
    use EntrustUserTrait; // add this trait to your user model 

    ... 
} 

我想用Entrust用户角色来使用Laravel内置的Auth系统。我怎么能混合这两个一起工作?正如我已阅读,它是不可能使用多个扩展。简单的解决方案

回答

0

和你一样的班级App\Models\Useruse EntrustUserTrait;放在班里面,你会好走