Get 2024 Templates Mega Bundle!14 Bootstrap, Vue & React Templates + 3 Vector Sets
Get for 99$

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
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (4)


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



Can someone help me with this problem?



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


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(