1

I used php artisan make:auth command in my Laravel project and this is how my unchanged App\Models\User.php looks like:

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

Now, according to Entrusts documentation I should change the User.php file to the following:

<?php

use Zizaco\Entrust\Traits\EntrustUserTrait;

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

    ...
}

I want to use Laravel built-in Auth system with Entrust user roles. How can I mix these two to work together? As I have read, it is not possible to use multiple extends. Any simple solutions?

nolem
  • 105
  • 10

1 Answers1

0

With you unchanged class App\Models\User put use EntrustUserTrait; inside the class and you will be good to go

oseintow
  • 7,221
  • 3
  • 26
  • 31