Show laravel nova field only for certain user roleLaravel Nova metrics filteringHow can I save additional data in my Laravel Nova fields?Enabling certain roles to access Laravel Nova dashboard?Laravel nova: How to override nova componentsLaravel Nova Action FieldsLaravel Nova: Select-Field with other modelsHow to show markdown field on index in Laravel nova?Laravel Nova conditional fields on formLaravel Nova Trix Field Call to Undefined Method Laravel/Nova/Fields/Trix::WithFiles()Laravel Nova User field with role
What word means "to make something obsolete"?
Would glacier 'trees' be plausible?
Why is Arya visibly scared in the library in S8E3?
My ID is expired, can I fly to the Bahamas with my passport?
Can Ghost kill White Walkers or Wights?
Sed Usage to update GRUB file
Why was the battle set up *outside* Winterfell?
Does this article imply that Turing-Computability is not the same as "effectively computable"?
Has any spacecraft ever had the ability to directly communicate with civilian air traffic control?
Do I really need diodes to receive MIDI?
What is the unit of the area when geometry attributes are calculated in QGIS?
How to explain the behaviour of TreeForm?
Why is C# in the D Major Scale?
Is one octave above tonic also considered as tonic?
A non-technological, repeating, phenomenon in the sky, holding its position in the sky for hours
Missed the connecting flight, separate tickets on same airline - who is responsible?
Is Jon mad at Ghost for some reason and is that why he won't acknowledge him?
Quoting Yourself
Junior developer struggles: how to communicate with management?
Identifying my late father's D&D stuff found in the attic
Catholic vs Protestant Support for Nazism in Germany
When and why did journal article titles become descriptive, rather than creatively allusive?
Airbnb - host wants to reduce rooms, can we get refund?
Is it cheaper to drop cargo than to land it?
Show laravel nova field only for certain user role
Laravel Nova metrics filteringHow can I save additional data in my Laravel Nova fields?Enabling certain roles to access Laravel Nova dashboard?Laravel nova: How to override nova componentsLaravel Nova Action FieldsLaravel Nova: Select-Field with other modelsHow to show markdown field on index in Laravel nova?Laravel Nova conditional fields on formLaravel Nova Trix Field Call to Undefined Method Laravel/Nova/Fields/Trix::WithFiles()Laravel Nova User field with role
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
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,resourceId'),
Password::make(__('Password'))
->onlyOnForms()
->creationRules('required', 'string', 'min:6')
->updateRules('nullable', 'string', 'min:6'),
//BelongsToMany::make(__("Businesses"),'businesses',Business::class),
MorphToMany::make(__('Roles'), 'roles', VyuldashevNovaPermissionRole::class),
MorphToMany::make(__('Permissions'), 'permissions', VyuldashevNovaPermissionPermission::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?
laravel-5 laravel-nova
add a comment |
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,resourceId'),
Password::make(__('Password'))
->onlyOnForms()
->creationRules('required', 'string', 'min:6')
->updateRules('nullable', 'string', 'min:6'),
//BelongsToMany::make(__("Businesses"),'businesses',Business::class),
MorphToMany::make(__('Roles'), 'roles', VyuldashevNovaPermissionRole::class),
MorphToMany::make(__('Permissions'), 'permissions', VyuldashevNovaPermissionPermission::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?
laravel-5 laravel-nova
add a comment |
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,resourceId'),
Password::make(__('Password'))
->onlyOnForms()
->creationRules('required', 'string', 'min:6')
->updateRules('nullable', 'string', 'min:6'),
//BelongsToMany::make(__("Businesses"),'businesses',Business::class),
MorphToMany::make(__('Roles'), 'roles', VyuldashevNovaPermissionRole::class),
MorphToMany::make(__('Permissions'), 'permissions', VyuldashevNovaPermissionPermission::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?
laravel-5 laravel-nova
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,resourceId'),
Password::make(__('Password'))
->onlyOnForms()
->creationRules('required', 'string', 'min:6')
->updateRules('nullable', 'string', 'min:6'),
//BelongsToMany::make(__("Businesses"),'businesses',Business::class),
MorphToMany::make(__('Roles'), 'roles', VyuldashevNovaPermissionRole::class),
MorphToMany::make(__('Permissions'), 'permissions', VyuldashevNovaPermissionPermission::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?
laravel-5 laravel-nova
laravel-5 laravel-nova
asked Mar 22 at 20:57
vimuthvimuth
2,08972848
2,08972848
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
After lots of digging I found an answer. We can use canSee method for this purpose. Here is my code.
use AppModelsUser as UserModel;
Text::make(__('Mobile token'),'mobile_token')
->canSee(function ($request)
return $request->user()->hasRole(UserModel::ROLE_SUPER_ADMIN);
),
You can accept your own answer
– keizah
Mar 22 at 23:45
it says I have to wait until tommorow :'( so sorry if any inconvenience happened
– vimuth
Mar 23 at 15:25
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55307678%2fshow-laravel-nova-field-only-for-certain-user-role%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
After lots of digging I found an answer. We can use canSee method for this purpose. Here is my code.
use AppModelsUser as UserModel;
Text::make(__('Mobile token'),'mobile_token')
->canSee(function ($request)
return $request->user()->hasRole(UserModel::ROLE_SUPER_ADMIN);
),
You can accept your own answer
– keizah
Mar 22 at 23:45
it says I have to wait until tommorow :'( so sorry if any inconvenience happened
– vimuth
Mar 23 at 15:25
add a comment |
After lots of digging I found an answer. We can use canSee method for this purpose. Here is my code.
use AppModelsUser as UserModel;
Text::make(__('Mobile token'),'mobile_token')
->canSee(function ($request)
return $request->user()->hasRole(UserModel::ROLE_SUPER_ADMIN);
),
You can accept your own answer
– keizah
Mar 22 at 23:45
it says I have to wait until tommorow :'( so sorry if any inconvenience happened
– vimuth
Mar 23 at 15:25
add a comment |
After lots of digging I found an answer. We can use canSee method for this purpose. Here is my code.
use AppModelsUser as UserModel;
Text::make(__('Mobile token'),'mobile_token')
->canSee(function ($request)
return $request->user()->hasRole(UserModel::ROLE_SUPER_ADMIN);
),
After lots of digging I found an answer. We can use canSee method for this purpose. Here is my code.
use AppModelsUser as UserModel;
Text::make(__('Mobile token'),'mobile_token')
->canSee(function ($request)
return $request->user()->hasRole(UserModel::ROLE_SUPER_ADMIN);
),
answered Mar 22 at 21:44
vimuthvimuth
2,08972848
2,08972848
You can accept your own answer
– keizah
Mar 22 at 23:45
it says I have to wait until tommorow :'( so sorry if any inconvenience happened
– vimuth
Mar 23 at 15:25
add a comment |
You can accept your own answer
– keizah
Mar 22 at 23:45
it says I have to wait until tommorow :'( so sorry if any inconvenience happened
– vimuth
Mar 23 at 15:25
You can accept your own answer
– keizah
Mar 22 at 23:45
You can accept your own answer
– keizah
Mar 22 at 23:45
it says I have to wait until tommorow :'( so sorry if any inconvenience happened
– vimuth
Mar 23 at 15:25
it says I have to wait until tommorow :'( so sorry if any inconvenience happened
– vimuth
Mar 23 at 15:25
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55307678%2fshow-laravel-nova-field-only-for-certain-user-role%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown