I'm using AdminLTE and Lara Entrust created a MyMenu Filter.php file to filter my options in accordance with the permission menu.
adminlte.php
'menu' => [
'MAIN NAVIGATION',
[
'text' => 'Blog',
'url' => 'admin/blog',
'permission' => 'create-post',
],
// CODE...
],
'filters' => [
// CODE...
App\MyMenuFilter::class,
],
MyMenuFilter.php
<?php
namespace App;
use JeroenNoten\LaravelAdminLte\Menu\Builder;
use JeroenNoten\LaravelAdminLte\Menu\Filters\FilterInterface;
class MyMenuFilter implements FilterInterface
{
public function transform($item, Builder $builder)
{
if (isset($item['permission']) && \Laratrust::can($item['permission'])) {
return false;
}
return $item;
}
}
My option in the "blog" menu need the create-post permission. But the "if" in mymenufilter.php returns false quando o usuário tem a permissão and does not create the menu.
But if I put a permission that the user does not have, it appears.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2cNgg5d
via IFTTT
Aucun commentaire:
Enregistrer un commentaire