roles icon indicating copy to clipboard operation
roles copied to clipboard

FatalErrorException in User.php line 42: Trait method can has not been applied, because there are collisions with other trait methods on App\User

Open montes2012 opened this issue 9 years ago • 4 comments

I get error

FatalErrorException in User.php line 42: Trait method can has not been applied, because there are collisions with other trait methods on App\User

<?php

namespace App;

use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Foundation\Auth\Access\Authorizable;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
use Bican\Roles\Traits\HasRoleAndPermission;
use Bican\Roles\Contracts\HasRoleAndPermission as HasRoleAndPermissionContract;

class User extends Model implements AuthenticatableContract,
                                    AuthorizableContract,
                                    CanResetPasswordContract,
                                    HasRoleAndPermissionContract
{
    use Authenticatable, Authorizable, CanResetPassword,  HasRoleAndPermission;

    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'users';

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['first_name', 'name', 'email', 'password','username'];

    /**
     * The attributes excluded from the model's JSON form.
     *
     * @var array
     */
    protected $hidden = ['password', 'remember_token'];
}


montes2012 avatar Nov 05 '15 01:11 montes2012

I have the same error. how i can solve it?

mbriceno avatar Nov 09 '15 21:11 mbriceno

@montes2012 in my case I could solve this by removing 'Authorizable' class from User model in this line: use Authenticatable, Authorizable, CanResetPassword, HasRoleAndPermission; now: use Authenticatable, CanResetPassword, HasRoleAndPermission;

mbriceno avatar Nov 09 '15 22:11 mbriceno

There is a collisions between @romanbican roles and Authorizable. Refer to @christopherburton PR for solutions.

frankiecmk avatar Nov 10 '15 03:11 frankiecmk

Check: #110, #133 Fix: #114

arcanedev-maroc avatar Nov 12 '15 18:11 arcanedev-maroc