Zizaco / entrust

Role-based Permissions for Laravel 5
MIT License
6.05k stars 1.29k forks source link

entrust Not Working With Lumen JWT #947

Open Zubair-Iftikhar opened 5 years ago

Zubair-Iftikhar commented 5 years ago

These Test Using Issue Try 1:

<?php

namespace App;

use Illuminate\Auth\Authenticatable;
use Laravel\Lumen\Auth\Authorizable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Tymon\JWTAuth\Contracts\JWTSubject;
use Zizaco\Entrust\Traits\EntrustUserTrait;

class User extends Model implements AuthenticatableContract, AuthorizableContract, JWTSubject
{
    use Authenticatable, Authorizable;
    use EntrustUserTrait; // add this trait to your user model
//More code There
}

Error:

Trait method can has not been applied, because there are collisions with other trait methods on App\User

Try 2:

class User extends Authenticatable
{

    use EntrustUserTrait { restore as private restoreA; }
    use SoftDeletes { restore as private restoreB; }

    /**
    * fix collision on restore methods in SoftDelete trait and Entrust trait
    */
   public function restore()
   {
       $this->restoreA();
        $this->restoreB();
   }
//More code There

}

Error:

Class App\User cannot extend from trait Illuminate\Auth\Authenticatable

Try 3:

namespace App;

use Illuminate\Auth\Authenticatable;
use Laravel\Lumen\Auth\Authorizable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Tymon\JWTAuth\Contracts\JWTSubject;
use Zizaco\Entrust\Traits\EntrustUserTrait;

class User extends Model implements AuthenticatableInterface
{
     use SoftDeletes;
    use Authenticatable;
   use EntrustUserTrait { restore as private restoreA; }
    use SoftDeletes { restore as private restoreB; }
    public function restore()
    {
        $this->restoreA();
        $this->restoreB();
    }
}

Error:

Interface 'App\AuthenticatableInterface' not found  

Environment

"php": ">=7.1.3", "flipbox/lumen-generator": "^5.6", "laravel/lumen-framework": "5.8.*", "laravelista/lumen-vendor-publish": "^2.1", "tymon/jwt-auth": "^1", "vlucas/phpdotenv": "^3.3", "zizaco/entrust": "5.2.x-dev"

lucasdcrk commented 5 years ago

This package is abandoned, you should consider using spatie/laravel-permission instead