I use Laravel 5.1, but this does not apply to this structure, it is rather a general PHP question.
There is a parent class with the specified characteristics:
namespace Illuminate\Foundation\Auth; 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; class User extends Model implements AuthenticatableContract, AuthorizableContract, CanResetPasswordContract { use Authenticatable, Authorizable, CanResetPassword; }
Then I have a User class about which I want to say that it extends from this:
namespace App\Api\V1\Models; use Illuminate\Foundation\Auth\User as Authenticatable; use Zizaco\Entrust\Traits\EntrustUserTrait; class User extends Authenticatable { use EntrustUserTrait { EntrustUserTrait::can insteadof \Illuminate\Foundation\Auth\Access\Authorizable; } }
EntrustUserTrait has a can() method that conflicts with the Authorizable attribute. However, the Authorizable property is in the parent class, so this causes the Required Trait wasn't added to App\Api\V1\Models\User error.
I searched around and there was a lot of information about overriding traits declared in a child class, but I cannot find anything about redefining traits from a parent class.
source share