如何将自定义字段添加到laravel护照客户端模型并进行检查 [英] How to add custom field to laravel passport client model and check it

查看:88
本文介绍了如何将自定义字段添加到laravel护照客户端模型并进行检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Laravel护照Client模型的oauth_clients表具有以下字段:

Laravel passport Client model has this fields on oauth_clients table:

name
secret
redirect
personal_access_client
password_client
revoked

以及如何将自定义字段request_domain_name添加到客户端凭据中,以便在每次请求时使用此自定义字段值检查请求域名?

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?

推荐答案

您可以创建单独的迁移

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');
});

在那之后,您可以扩展Client模型并将request_domain_name列添加到fillable属性,这样您就可以对其进行检查.

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',
    ];
}

这篇关于如何将自定义字段添加到laravel护照客户端模型并进行检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆