dusterio / lumen-passport

Making Laravel Passport work with Lumen
MIT License
654 stars 139 forks source link

Restrictions with models #176

Open alejosv opened 1 year ago

alejosv commented 1 year ago

I'm working with this package, my project I force myself in rename the passport's tables and this issue I can resolved created a own provider as follows:

<?php

namespace App\Providers;

use Laravel\Passport\Passport;
use Dusterio\LumenPassport\PassportServiceProvider;
use App\Models\{User, Token, Client, AuthCode, PersonalAccessClient, RefreshToken};

class TelesaludServiceProvider extends PassportServiceProvider 
{ 

    public function boot()
    {

        Passport::useTokenModel(Token::class);
        Passport::useClientModel(Client::class);
        Passport::useAuthCodeModel(AuthCode::class);
        Passport::usePersonalAccessClientModel(PersonalAccessClient::class);
        Passport::useRefreshTokenModel(RefreshToken::class);

    }

}

Where each model in my project I haved to renamed the table as follows:

<?php

namespace App\Models;

use Laravel\Passport\Token as TokenPassport;

class Token extends TokenPassport 
{
    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'telesa_oauth_access_tokens';
}

The problem is in this code:

https://github.com/dusterio/lumen-passport/blob/9729c62dc3ccbcf4b31c173817223851f84cfd98/src/Http/Controllers/AccessTokenController.php#L95-L101

https://github.com/dusterio/lumen-passport/blob/9729c62dc3ccbcf4b31c173817223851f84cfd98/src/Console/Commands/Purge.php#L35-L43

So, your package call the table with the Passport original value, so if I make a print at Token::class I have: Laravel\Passport\Token when the correct behavior is get App\Model\Token

I'm new in Lumel and Passport but I suppose this is the right way to can use different tables names