PHP code example of hexters / rolevel

1. Go to this page and download the library: Download hexters/rolevel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hexters / rolevel example snippets


$ php artisan vendor:publish --tag=rolevel

$ php artisan migrate



  return [
    [
      'display' => 'Menu Access', // display name
      'gate' => 'module.access.index', // must uniq
      'url' => null, // URL can set null if menu have submenu
      'classId' => '', // id attribute
      'className' => '', // class style attribute
      'classIcon' => '', // font icon code

      /*
      | ------ Submenu ------
      */
      'childs' => [
        [
          'display' => 'Assign Permissions',
          'gate' => 'module.access.assign.permission.index',
          'url' => '/admin/assign/permission',
          'classId' => '',
          'className' => '',
          'classIcon' => '',

          'permissions' => [
            [
              'gate' => 'module.access.assign.permission.show',
              'name' => 'Detail Permissions', // title
              'description' => 'Show detail for permission' // info description
            ],

            [
              // More permission...
            ]
          ]
        ],

        [
          // More submenu...
        ]
      ]
    ],

    [
      // More menu...
    ]
  ];

@if(auth()->check())
  @php
      $permissions = auth()->user()->permissions();
      $viewMenu = function($menus) use (&$viewMenu, $permissions) {
          $html = '';
          foreach($menus as $menu) {
              if(in_array($menu['gate'], $permissions)) {
                  $html .= view('vendor.rolevel.menu', ['menu' => $menu, 'view' => $viewMenu]);
              }
          }
          return $html;
      }
  @endphp

  <ul>
      <li><a href="{{ url('/dashboard') }}">Dashboard</a></li>
      {!! $viewMenu(rolevel()->menus()) !!}
  </ul>
@endif

@yield('content')