entrust icon indicating copy to clipboard operation
entrust copied to clipboard

Extend the User model from Authenticatable instead \Eloquent

Open eloyucu opened this issue 9 years ago • 3 comments

Hello everyone.
I am using the entrust package, and one of the instructions to use it is to change the User model, like this

class User extends Eloquent

And after I make php artisan make:auth to autogenerate the login and sign up views and controllers... the bad thing is that a lot of functions of the method (auth), require that the User model extends from Authenticable, I make this:

namespace App\Models;

use Illuminate\Foundation\Auth\User as Authenticatable;

use Zizaco\Entrust\Traits\EntrustUserTrait;

class User extends Authenticatable
{
    use EntrustUserTrait;
        /* more and more*/
}

In this way it seems that everything works... so... is there any really needing to extend from \Eloquent or can I let how I have.

Thank you very much.

eloyucu avatar Jun 06 '16 14:06 eloyucu

try

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Auth\Authenticatable;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;

use Zizaco\Entrust\Traits\EntrustUserTrait;

class User extends Model implements AuthenticatableContract, CanResetPasswordContract
{
    use EntrustUserTrait, Authenticatable, CanResetPassword;
    /* more and more*/
}

justenj avatar Jun 09 '16 17:06 justenj

I´ll try, thanks!!

eloyucu avatar Jun 24 '16 12:06 eloyucu

thank u

nuriizatti avatar Dec 09 '19 07:12 nuriizatti