I'm using Laravel 5.1 but this isn't specific to that framework, it's more of a general PHP question.
There's a parent class with traits specified:
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 the User class I'm concerned with extending from that:
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;
}
}
The EntrustUserTrait has a can() method that conflicts with the Authorizable trait. However, the Authorizable trait is on the parent class, so this throws an error Required Trait wasn't added to App\Api\V1\Models\User.
I've searched around and there's plenty of information on overriding traits declared within the child class, but I can't seem to find anything about overriding traits from the parent class.
canwill override the parent'scan.