How to add custom field to laravel passport client model and check it

时间秒杀一切 提交于 2020-01-16 17:26:46

问题


Laravel passport Client model has this fields on oauth_clients table:

name
secret
redirect
personal_access_client
password_client
revoked

And how I can add my custom filed request_domain_name to client credentials for check requesting domain name with this custom field value on every request?


回答1:


You can create a separate migration

php artisan make:migration alter_oauth_clients_table_request_domain_name --table=oauth_clients

and inside your migration define new column

Schema::table('oauth_clients', function (Blueprint $table) {
    $table->string('request_domain_name');
});

After that, you can extend Client model and add request_domain_name column to fillable property, than you'll be able to check it.

class Client extends \Laravel\Passport\Client
{
    protected $fillable = [
        'name',
        'secret',
        'redirect',
        'personal_access_client',
        'password_client',
        'revoked',
        'request_domain_name',
    ];
}


来源:https://stackoverflow.com/questions/56285892/how-to-add-custom-field-to-laravel-passport-client-model-and-check-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!