{"id":21499854,"url":"https://github.com/hexters/rolevel","last_synced_at":"2025-03-17T13:12:59.615Z","repository":{"id":56984058,"uuid":"205294365","full_name":"hexters/rolevel","owner":"hexters","description":"Role \u0026 Permissions base on file for laravel","archived":false,"fork":false,"pushed_at":"2020-03-05T03:53:46.000Z","size":49,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-16T14:57:08.818Z","etag":null,"topics":["laravel-roles","laravel-roles-permissions","roles"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hexters.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-30T03:04:59.000Z","updated_at":"2023-01-09T12:58:08.000Z","dependencies_parsed_at":"2022-08-21T11:50:37.856Z","dependency_job_id":null,"html_url":"https://github.com/hexters/rolevel","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexters%2Frolevel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexters%2Frolevel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexters%2Frolevel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexters%2Frolevel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hexters","download_url":"https://codeload.github.com/hexters/rolevel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244039241,"owners_count":20387835,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel-roles","laravel-roles-permissions","roles"],"created_at":"2024-11-23T17:19:02.346Z","updated_at":"2025-03-17T13:12:59.596Z","avatar_url":"https://github.com/hexters.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## ROLEVEL\n\nPackage for hendle role \u0026 permission in laravel\n\n### Require\n* Bootstrap 4\n\n### Installation\n\nYou can install this package via composer:\n```\n$ composer require hexters/rolevel\n```\n\nPublish vendor\n```\n$ php artisan vendor:publish --tag=rolevel\n```\n\nPut trait to your User Model\n```\n\u003c?php\n\nnamespace App;\n\n. . .\n\nuse Hexters\\Rolevel\\RolevelModelTrait;\n\nclass User extends Authenticatable {\n\n    use Notifiable, RolevelModelTrait;\n\n    . . .\n```\n\nMigrate rolevel database\n```\n$ php artisan migrate\n```\n\n### Getting Started\n\nOpen file menu \u0026 permission in folder `app/Roles/menu_and_permissions.php`. In this file you can set menu and permission to provide access to your application module, for example.\n```\n\u003c?php\n\n  return [\n    [\n      'display' =\u003e 'Menu Access', // display name\n      'gate' =\u003e 'module.access.index', // must uniq\n      'url' =\u003e null, // URL can set null if menu have submenu\n      'classId' =\u003e '', // id attribute\n      'className' =\u003e '', // class style attribute\n      'classIcon' =\u003e '', // font icon code\n\n      /*\n      | ------ Submenu ------\n      */\n      'childs' =\u003e [\n        [\n          'display' =\u003e 'Assign Permissions',\n          'gate' =\u003e 'module.access.assign.permission.index',\n          'url' =\u003e '/admin/assign/permission',\n          'classId' =\u003e '',\n          'className' =\u003e '',\n          'classIcon' =\u003e '',\n\n          'permissions' =\u003e [\n            [\n              'gate' =\u003e 'module.access.assign.permission.show',\n              'name' =\u003e 'Detail Permissions', // title\n              'description' =\u003e 'Show detail for permission' // info description\n            ],\n\n            [\n              // More permission...\n            ]\n          ]\n        ],\n\n        [\n          // More submenu...\n        ]\n      ]\n    ],\n\n    [\n      // More menu...\n    ]\n  ];\n```\nAfter that please put script in your master layout, for showing menu access.\n\n```\n@if(auth()-\u003echeck())\n  @php\n      $permissions = auth()-\u003euser()-\u003epermissions();\n      $viewMenu = function($menus) use (\u0026$viewMenu, $permissions) {\n          $html = '';\n          foreach($menus as $menu) {\n              if(in_array($menu['gate'], $permissions)) {\n                  $html .= view('vendor.rolevel.menu', ['menu' =\u003e $menu, 'view' =\u003e $viewMenu]);\n              }\n          }\n          return $html;\n      }\n  @endphp\n\n  \u003cul\u003e\n      \u003cli\u003e\u003ca href=\"{{ url('/dashboard') }}\"\u003eDashboard\u003c/a\u003e\u003c/li\u003e\n      {!! $viewMenu(rolevel()-\u003emenus()) !!}\n  \u003c/ul\u003e\n@endif\n\n@yield('content')\n```\nYou can custom style for your menu, open blade file in `resources/views/vendor/rolevel/menu.blade.php`\n\nYou should assign role to your User account before.\n```\n  $user = App\\User::find(1);\n  $role = App\\Role::find(1);\n\n  $user-\u003eroles()-\u003esync([ $role-\u003eid ], false);\n```\n\nIn your any controller you should declaration `Gate` to provide access to your module, for example\n```\n\u003c?php\n\nnamespace App\\Http\\Controllers;\n\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Support\\Facades\\Gate;\n\nclass MenuAccessController extends Controller {\n\n    /**\n     * Display a listing of the resource.\n     *\n     * @return \\Illuminate\\Http\\Response\n     */\n    public function index()\n    {\n      /**\n      * Get module.access.assign.permission.index from gate in file menu_and_permissions.php\n      */\n      if(Gate::denies('module.access.assign.permission.index')) abort(403);\n\n      return view('access.index');\n    }\n\n    . . .\n```\nIn your blade\n```\n@can('module.access.assign.permission.store')\n  \u003ca href=\"{{ url('/admin/account/create') }}\"\u003eCreate Account\u003c/a\u003e\n@endcan\n\n// OR\n\nif($user-\u003ecan('module.access.assign.permission.store')) {\n  // Condition\n}\n\n```\nYou can check [this link](https://laravel.com/docs/5.8/authorization#via-blade-templates) and [this link](https://laravel.com/docs/5.8/authorization#via-the-user-model)\n\nCheck config file in `config/rolevel.php` if you have change such as:\n  * Model Role possition\n  * Link admin prefix\n  * Middleware for access module assign\n  * Template reference\n\nFor default you can access module assign permission in `http://localhost:8000/admin/roles`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexters%2Frolevel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhexters%2Frolevel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexters%2Frolevel/lists"}