Why don't use Trait?
I think Trait extended model is more usefull. Just like softDelte. Is anyone agree
trait is only useful if you are trying to expose some helper methods into the class,
but as for Baum's case, it's more than that... Baum uses polymorphism.
you can't detect if the class is using a trait using instanceof, but there are non-conventional ways to detect it.
The problem is now I cant use this package with my User model that alredy extends Authenticable
@MichaelObi, I had the same problem and solved it that way:
Take a look at this file: /vendor/laravel/framework/src/Illuminate/Foundation/Auth/User.php
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;
}
Since Baum\Node is extending Eloquent Model, just like the mentioned User class does, I have changed my User class to this:
use Baum\Node;
use Illuminate\Notifications\Notifiable;
use Illuminate\Auth\Authenticatable;
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 Node implements
AuthenticatableContract,
AuthorizableContract,
CanResetPasswordContract
{
use Authenticatable, Authorizable, CanResetPassword, Notifiable;
[...]
Don't forget to update the database with parent_id, lft,rgt and depth.