Restrictions with models
alejosv opened this issue · 0 comments
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:
lumen-passport/src/Http/Controllers/AccessTokenController.php
Lines 95 to 101 in 9729c62
lumen-passport/src/Console/Commands/Purge.php
Lines 35 to 43 in 9729c62
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