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;








1















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?










share|improve this question




























    1















    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?










    share|improve this question
























      1












      1








      1








      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?










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 22 at 20:57









      vimuthvimuth

      2,08972848




      2,08972848






















          1 Answer
          1






          active

          oldest

          votes


















          0














          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);
          ),





          share|improve this answer























          • 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












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



          );













          draft saved

          draft discarded


















          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









          0














          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);
          ),





          share|improve this answer























          • 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
















          0














          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);
          ),





          share|improve this answer























          • 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














          0












          0








          0







          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);
          ),





          share|improve this answer













          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);
          ),






          share|improve this answer












          share|improve this answer



          share|improve this answer










          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


















          • 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




















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript