更改航海家模型 [英] Change voyager model
本文介绍了更改航海家模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在Voyager的User类上添加一些变形器,但是我不会在供应商文件夹中进行任何更改,并且Voyages在包中使用了User模型.我有可能以某种方式更改此设置吗?
I want to add some mutators on Voyager's User class, but I won't change anything inside vendor folder, and Voyages uses a User model inside the package. Is it possible for me to, somehow, change this?
推荐答案
足够简单.将默认的Laravel用户模型修改为
Simple enough. Modify the default Laravel User model to
<?php
namespace App\Models;
use TCG\Voyager\Models\User as VoyagerUser;
class User extends VoyagerUser {
// add custom mutators and other code in here
}
然后您可以按照@aimme所说的那样更新app/config/voyager.php
并将其保存为
Then you can update app/config/voyager.php
as @aimme said and have it as
'user' => [
'add_default_role_on_register' => true,
'default_role' => 'user',
'admin_permission' => 'browse_admin',
'namespace' => App\User::class,
],
通过这种方式,您可以将Voyager的用户模型的功能带到您自己的手中,而不会涉及黑客.
This way you bring in the power of Voyager's User model to your own with no hackery involved.
这篇关于更改航海家模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文