#Laravel Nova activate mainMenu by user->hasRole()

8 messages · Page 1 of 1 (latest)

spring mulch
#

In the "NovaServiceProvider"
I want to make an menu only for not-admins, I proof if is admin but have no Auth or $request

if ($request->user()->hasRole('super-admin')) {

then I create an Menu

Nova::mainMenu(function (Request $request) {

At this Point I have an $request, but the mainMenu has created and the menu are empty for all admins.
I don't know if is possible to

if (admin){
  $this->deleteThisInstanceAndShowAll;
}

or get the $request bevor create the menu

mellow zenith
#

You might be able to use Auth()::user(), but I think ServiceProviders happen before Middleware - so you might not have access.

#

Auth::user() sorry.

oblique frost
spring mulch
mellow zenith
#

But his code shows how you could do it.

spring mulch
#

I try it next time on work but I believe the super-admin not get ALL resources automaticly like without the function

#

I should use an similar functionality:
if (!env('DEBUG')){
custom_menu
}
that is a good enough helper
Thanks for help