1. Go to this page and download the library: Download 4msar/laravel-role-manager 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/ */
return [
/**
* Permission List
* Here, you can declare your needed permission, the package will be add this permission automatically
* to the database( via middle-ware).
* key name is the permission name and value is the details name showing for management.
*/
"add_permission_dynamically" => false, // Make true if you want to add permission from bellow permissions array
"permissions" => [
// 'permission_name' => 'permission_details'
'view_home' => 'View Admin Dashboard',
'view_users' => 'View Admin Users',
],
'unauthorized_action' => '',
'unauthorized_action_type' => [
'route' => [
'name' => 'welcome',
'data' => [],
],
'url' => [
'name' => '/login',
'data' => [],
],
'abort' => [
'type' => '403',
],
'dump' => [
'data' => 'Dumping a unauthorized message.',
]
],
"database" => [
"role_table" => "roles",
"permission_table" => "permissions",
"role_permission_table" => "permission_role",
],
];
use Illuminate\Foundation\Auth\User as Authenticatable;
use MSAR\RoleManager\Traits\HasPermission;;
class User extends Authenticatable
{
use HasPermission;
// ...
}