Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

Laravel-permission-Spatie not working


I am trying to put permissions in the left side menu in the file located in config->global->menu.php

I tried in the following way but it only detects the first permission, I would like to detect several

'permission' => 'system.roles.master','system.permisos', 'system.auditoria','system.registro',
'permission' => 'system.roles.master|system.permisos|system.auditoria|system.registro',

I tried both ways above and nothing works.
also in the following way, but it doesn't work either
'permission' => 'system.roles.master',
'permission' => 'system.permisos'',
'permission' => 'system.registro'',


I already put the following in app->http->kernel

protected $routeMiddleware = [


'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class,
'permission' => \Spatie\Permission\Middlewares\PermissionMiddleware::class,
'role_or_permission' => \Spatie\Permission\Middlewares\RoleOrPermissionMiddleware::class,

]

and it does not work


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (4)


Hi Jesus Sanjuan Mendez,

If you check this file; app/Core/Adapters/Menu.php in filterMenuPermissions() function.
We use hasAnyPermission() and hasAnyRole() function to check each menu item permission and role config. Hope this can help with your customization.

See also Laravel-permission-Spatie docs.


Thanks



Can someone help me with this problem?



Hi,

Could you please add it as an array?


"permission" => [  "system.roles.master","system.permisos", "system.auditoria","system.registro", ],


Thanks



I already tried it that way but it doesn't work


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(