Hi my user model has this code.
const ROLE_SUPER_ADMIN = "SUPER_ADMIN";
public function isSuperAdmin(){
return $this->hasRole(self::ROLE_SUPER_ADMIN);
}
and roles table has 'SUPER_ADMIN'
And I have create a resource for user table has this,
public function fields(Request $request)
{
return [
ID::make()->sortable(),
Gravatar::make(),
Text::make(__('Name'),'name')
->sortable()
->rules('required', 'max:255'),
Text::make(__('Surname'),'surname')
->sortable()
->rules('required', 'max:255'),
Text::make(__('Mobile token'),'mobile_token'),
Text::make(__('Email'))
->sortable()
->rules('required', 'email', 'max:254')
->creationRules('unique:users,email')
->updateRules('unique:users,email,'),
Password::make(__('Password'))
->onlyOnForms()
->creationRules('required', 'string', 'min:6')
->updateRules('nullable', 'string', 'min:6'),
//BelongsToMany::make(__("Businesses"),'businesses',Business::class),
MorphToMany::make(__('Roles'), 'roles', \Vyuldashev\NovaPermission\Role::class),
MorphToMany::make(__('Permissions'), 'permissions', \Vyuldashev\NovaPermission\Permission::class),
];
What I need is to show this Text::make(__('Mobile token'),'mobile_token'), field only to SUPER_ADMIN users. And other fields without restrictions. Is there a way to do that?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire