public function actionDesactivate($id) { $route = Route::where('id', $id)->first(); if (!$route) { return response()->not_found('Ruta no encontrada'); } $route->active = 0; $route->save(); return response()->json(['message' => 'Ruta ha sido desactivada']); }
private function validateUnique() { $routeDuplicate = Route::where('origen', $this->origen)->where('destiny', $this->destiny); if ($this->id != null) { $routeDuplicate->where('id', '!=', $this->id); } $routeDuplicate = $routeDuplicate->first(); if ($routeDuplicate) { return false; } else { return true; } }
/** * Run the database seeds. * * @return void */ public function run() { //////////////////////////////////// // Load the routes Route::loadLaravelRoutes(); // Look for and delete route named 'do-not-load' if it exist. // That route is used to test the Authorization middleware and should not be loaded automatically. $routeToDelete = Route::where('name', 'do-not-load')->get()->first(); if ($routeToDelete) { Route::destroy($routeToDelete->id); } //////////////////////////////////// // Create basic set of permissions $permGuestOnly = Permission::create(['name' => 'guest-only', 'display_name' => 'Guest only access', 'description' => 'Only guest users can access these.', 'enabled' => true]); $permOpenToAll = Permission::create(['name' => 'open-to-all', 'display_name' => 'Open to all', 'description' => 'Everyone can access these, even unauthenticated (guest) users.', 'enabled' => true]); $permBasicAuthenticated = Permission::create(['name' => 'basic-authenticated', 'display_name' => 'Basic authenticated', 'description' => 'Basic permission after being authenticated.', 'enabled' => true]); // Create a few permissions for the admin|security section $permManageUsers = Permission::create(['name' => 'manage-users', 'display_name' => 'Manage users', 'description' => 'Allows a user to manage the site users.', 'enabled' => true]); $permManageRoles = Permission::create(['name' => 'manage-roles', 'display_name' => 'Manage roles', 'description' => 'Allows a user to manage the site roles.', 'enabled' => true]); $permManagePermissions = Permission::create(['name' => 'manage-permissions', 'display_name' => 'Manage permissions', 'description' => 'Allows a user to manage the site permissions.', 'enabled' => true]); $permManageRoutes = Permission::create(['name' => 'manage-routes', 'display_name' => 'Manage routes', 'description' => 'Allows a user to Manage the site routes.', 'enabled' => true]); // Create a few permissions for the admin|audit section $permAuditLogView = Permission::create(['name' => 'audit-log-view', 'display_name' => 'View audit log', 'description' => 'Allows a user to view the audit log.', 'enabled' => true]); $permAuditReplay = Permission::create(['name' => 'audit-log-replay', 'display_name' => 'Replay audit log item', 'description' => 'Allows a user to replay items from the audit log.', 'enabled' => true]); $permAuditPurge = Permission::create(['name' => 'audit-log-purge', 'display_name' => 'Purge audit log', 'description' => 'Allows a user to purge old items from the audit log.', 'enabled' => true]); //////////////////////////////////// // Associate open-to-all permission to some routes $routeBackslash = Route::where('name', 'backslash')->get()->first(); $routeBackslash->permission()->associate($permOpenToAll); $routeBackslash->save(); $routeHome = Route::where('name', 'home')->get()->first(); $routeHome->permission()->associate($permOpenToAll); $routeHome->save(); $routeFaust = Route::where('name', 'faust')->get()->first(); $routeFaust->permission()->associate($permOpenToAll); $routeFaust->save(); // Associate basic-authenticated permission to the dashboard route $routeDashboard = Route::where('name', 'dashboard')->get()->first(); $routeDashboard->permission()->associate($permBasicAuthenticated); $routeDashboard->save(); // Associate the audit-log permissions $routeAuditView = Route::where('name', 'admin.audit.index')->get()->first(); $routeAuditView->permission()->associate($permAuditLogView); $routeAuditView->save(); $routeAuditPurge = Route::where('name', 'admin.audit.purge')->get()->first(); $routeAuditPurge->permission()->associate($permAuditPurge); $routeAuditPurge->save(); $routeAuditReplay = Route::where('name', 'admin.audit.replay')->get()->first(); $routeAuditReplay->permission()->associate($permAuditReplay); $routeAuditReplay->save(); // Associate manage-permission permissions to routes starting with 'admin.permissions.' $managePermRoutes = Route::where('name', 'like', "admin.permissions.%")->get()->all(); foreach ($managePermRoutes as $route) { $route->permission()->associate($permManagePermissions); $route->save(); } // Associate manage-roles permissions to routes starting with 'admin.roles.' $manageRoleRoutes = Route::where('name', 'like', "admin.roles.%")->get()->all(); foreach ($manageRoleRoutes as $route) { $route->permission()->associate($permManageRoles); $route->save(); } // Associate manage-routes permissions to routes starting with 'admin.routes.' $manageRouteRoutes = Route::where('name', 'like', "admin.routes.%")->get()->all(); foreach ($manageRouteRoutes as $route) { $route->permission()->associate($permManageRoutes); $route->save(); } // Associate manage-users permissions to routes starting with 'admin.users.' $manageUserRoutes = Route::where('name', 'like', "admin.users.%")->get()->all(); foreach ($manageUserRoutes as $route) { $route->permission()->associate($permManageUsers); $route->save(); } //////////////////////////////////// // Create role: admins $roleAdmins = Role::create(["name" => "admins", "display_name" => "Administrators", "description" => "Administrators have no restrictions", "enabled" => true]); // Create role: users // Assign permission basic-authenticated $roleUsers = Role::create(["name" => "users", "display_name" => "Users", "description" => "All authenticated users", "enabled" => true]); $roleUsers->perms()->attach($permBasicAuthenticated->id); // Create role: user-manager // Assign permission manage-users $roleUserManagers = Role::create(["name" => "user-managers", "display_name" => "User managers", "description" => "User managers are granted all permissions to the Admin|Users section.", "enabled" => true]); $roleUserManagers->perms()->attach($permManageUsers->id); // Create role: role-manager // Assign permission: manage-roles $roleRoleManagers = Role::create(["name" => "role-managers", "display_name" => "Role managers", "description" => "Role managers are granted all permissions to the Admin|Roles section.", "enabled" => true]); $roleRoleManagers->perms()->attach($permManageRoles->id); // Create role: audit-viewers // Assign permission: audit-log-view $roleAuditViewers = Role::create(["name" => "audit-viewers", "display_name" => "Audit viewers", "description" => "Users allowed to view the audit log.", "enabled" => true]); $roleAuditViewers->perms()->attach($permAuditLogView->id); // Create role: audit-replayers // Assign permission: audit-log-replay $roleAuditReplayers = Role::create(["name" => "audit-replayers", "display_name" => "Audit replayers", "description" => "Users allowed to replay items from the audit log.", "enabled" => true]); $roleAuditReplayers->perms()->attach($permAuditReplay->id); // Create role: audit-purgers // Assign permission: audit-log-purge $roleAuditPurgers = Role::create(["name" => "audit-purgers", "display_name" => "Audit purgers", "description" => "Users allowed to purge old items from the audit log.", "enabled" => true]); $roleAuditPurgers->perms()->attach($permAuditPurge->id); // Create regency data $regency_data = array('Trưởng Phòng', 'Nhân viên'); foreach ($regency_data as $data) { $regency = Regency::create(['name' => $data, 'enabled' => true]); } // Create department data $department_data = array('Quản lý', 'Kinh doanh', 'Sản xuất', 'Marketing-degital', 'Kế toán', 'Giao nhận', 'Thiết kế'); foreach ($department_data as $data) { $department = Department::create(['name' => $data, 'enabled' => true]); } //////////////////////////////////// // Create user: root // Assign membership to role admins, membership to role users is // automatic. $userRoot = User::create(["first_name" => "Root", "last_name" => "SuperUser", "username" => "root", "email" => "*****@*****.**", "password" => "thienhb", "gender" => true, "auth_type" => "internal", "enabled" => true, "regency_id" => true, "department_id" => true]); $userRoot->roles()->attach($roleAdmins->id); }
/** * Run the database seeds. * * @return void */ public function run() { // TODO: Remove this before release... // Look for and delete route named 'do-not-pre-load' if it exist. // That route is used to test a failure with the Authorization middleware and should not be loaded automatically. $routeToDelete = Route::where('name', 'test-acl.do-not-pre-load')->get()->first(); if ($routeToDelete) { Route::destroy($routeToDelete->id); } $testUserOne = User::create(['username' => 'user1', 'first_name' => 'User', 'last_name' => 'One', 'email' => '*****@*****.**', "password" => "Password1", "auth_type" => "internal", "enabled" => true]); $testUserTwo = User::create(['username' => 'user2', 'first_name' => 'User', 'last_name' => 'Two', 'email' => '*****@*****.**', "password" => "Password1", "auth_type" => "internal", "enabled" => true]); $testUserThree = User::create(['username' => 'user3', 'first_name' => 'User', 'last_name' => 'Three', 'email' => '*****@*****.**', "password" => "Password1", "auth_type" => "internal", "enabled" => true]); $testUserFour = User::create(['username' => 'user4', 'first_name' => 'User', 'last_name' => 'Four', 'email' => '*****@*****.**', "password" => "Password1", "auth_type" => "internal", "enabled" => true]); $testUserFive = User::create(['username' => 'user5', 'first_name' => 'User', 'last_name' => 'Five', 'email' => '*****@*****.**', "password" => "Password1", "auth_type" => "internal", "enabled" => true]); $testUserSix = User::create(['username' => 'user6', 'first_name' => 'User', 'last_name' => 'Six', 'email' => '*****@*****.**', "password" => "Password1", "auth_type" => "internal", "enabled" => true]); $testUserSeven = User::create(['username' => 'user7', 'first_name' => 'User', 'last_name' => 'Seven', 'email' => '*****@*****.**', "password" => "Password1", "auth_type" => "internal", "enabled" => true]); $testUserEight = User::create(['username' => 'user8', 'first_name' => 'User', 'last_name' => 'Eight', 'email' => '*****@*****.**', "password" => "Password1", "auth_type" => "internal", "enabled" => true]); $testUserNine = User::create(['username' => 'user9', 'first_name' => 'User', 'last_name' => 'Nine', 'email' => '*****@*****.**', "password" => "Password1", "auth_type" => "internal", "enabled" => true]); $testUserTen = User::create(['username' => 'user10', 'first_name' => 'User', 'last_name' => 'Ten', 'email' => '*****@*****.**', "password" => "Password1", "auth_type" => "internal", "enabled" => true]); $testUserEleven = User::create(['username' => 'user11', 'first_name' => 'User', 'last_name' => 'Eleven', 'email' => '*****@*****.**', "password" => "Password1", "auth_type" => "internal", "enabled" => true]); $testUserTwelve = User::create(['username' => 'user12', 'first_name' => 'User', 'last_name' => 'Twelve', 'email' => '*****@*****.**', "password" => "Password1", "auth_type" => "internal", "enabled" => true]); $testUserThirteen = User::create(['username' => 'user13', 'first_name' => 'User', 'last_name' => 'Thirteen', 'email' => '*****@*****.**', "password" => "Password1", "auth_type" => "internal", "enabled" => true]); $testUserFourteen = User::create(['username' => 'user14', 'first_name' => 'User', 'last_name' => 'Fourteen', 'email' => '*****@*****.**', "password" => "Password1", "auth_type" => "internal", "enabled" => true]); $testUserFifteen = User::create(['username' => 'user15', 'first_name' => 'User', 'last_name' => 'Fifteen', 'email' => '*****@*****.**', "password" => "Password1", "auth_type" => "internal", "enabled" => true]); ///////// // Create a few test permissions for the flash-test pages. $permTestLevelSuccess = Permission::create(['name' => 'test-level-success', 'display_name' => 'Test level success', 'description' => 'Testing level success', 'enabled' => true]); $permTestLevelInfo = Permission::create(['name' => 'test-level-info', 'display_name' => 'Test level info', 'description' => 'Testing level info', 'enabled' => true]); $permTestLevelWarning = Permission::create(['name' => 'test-level-warning', 'display_name' => 'Test level warning', 'description' => 'Testing level warning', 'enabled' => true]); $permTestLevelError = Permission::create(['name' => 'test-level-error', 'display_name' => 'Test level error', 'description' => 'Testing level error', 'enabled' => true]); //////////////////////////////////// // Create some roles for the flash test pages. //////////////////////////////////// // Success $roleFlashSuccessViewer = Role::create(["name" => "flash-success-viewer", "display_name" => "Flash success viewer", "description" => "Can see the success flash test page.", "enabled" => true]); // Assign permission TestLevelSuccess $roleFlashSuccessViewer->perms()->attach($permTestLevelSuccess->id); // Assign user membership to role $roleFlashSuccessViewer->users()->attach($testUserTwo->id); // Info $roleFlashInfoViewer = Role::create(["name" => "flash-info-viewer", "display_name" => "Flash info viewer", "description" => "Can see the info flash test page.", "enabled" => true]); // Assign permission Info and Success to the InfoViewer role. $roleFlashInfoViewer->perms()->attach($permTestLevelInfo->id); $roleFlashInfoViewer->perms()->attach($permTestLevelSuccess->id); // Assign user membership to role $roleFlashInfoViewer->users()->attach($testUserThree->id); // Warning $roleFlashWarningViewer = Role::create(["name" => "flash-warning-viewer", "display_name" => "Flash warning viewer", "description" => "Can see the warning flash test page.", "enabled" => true]); // Assign permission Warning, Info and Success to the WarningViewer role. $roleFlashWarningViewer->perms()->attach($permTestLevelWarning->id); $roleFlashWarningViewer->perms()->attach($permTestLevelInfo->id); $roleFlashWarningViewer->perms()->attach($permTestLevelSuccess->id); // Assign user membership to role $roleFlashWarningViewer->users()->attach($testUserFour->id); // Error $roleFlashErrorViewer = Role::create(["name" => "flash-error-viewer", "display_name" => "Flash error viewer", "description" => "Can see the error flash test page.", "enabled" => true]); // Assign permission Error, Warning, Info and Success to the ErrorViewer role. $roleFlashErrorViewer->perms()->attach($permTestLevelError->id); $roleFlashErrorViewer->perms()->attach($permTestLevelWarning->id); $roleFlashErrorViewer->perms()->attach($permTestLevelInfo->id); $roleFlashErrorViewer->perms()->attach($permTestLevelSuccess->id); // Assign user membership to role $roleFlashErrorViewer->users()->attach($testUserFive->id); ///////// // Find basic-authenticated permission. $permBasicAuthenticated = Permission::where('name', 'basic-authenticated')->first(); // Find guest-only permission. $permGuestOnly = Permission::where('name', 'guest-only')->first(); // Find open-to-all permission. $permOpenToAll = Permission::where('name', 'open-to-all')->first(); // Find admin-settings permission. $permAdminSettings = Permission::where('name', 'admin-settings')->first(); //////////////////////////////////// // Associate some permission to acl test routes $routeTestACLHome = Route::where('name', 'test-acl.home')->get()->first(); $routeTestACLHome->permission()->associate($permOpenToAll); $routeTestACLHome->save(); // $routeTestACLAdmins = Route::where('name', 'test-acl.admins')->get()->first(); $routeTestACLAdmins->permission()->associate($permAdminSettings); $routeTestACLAdmins->save(); // $routeTestACLBasicAuthenticated = Route::where('name', 'test-acl.basic-authenticated')->get()->first(); $routeTestACLBasicAuthenticated->permission()->associate($permBasicAuthenticated); $routeTestACLBasicAuthenticated->save(); // $routeTestACLGuestOnly = Route::where('name', 'test-acl.guest-only')->get()->first(); $routeTestACLGuestOnly->permission()->associate($permGuestOnly); $routeTestACLGuestOnly->save(); // $routeTestACLOpenToAll = Route::where('name', 'test-acl.open-to-all')->get()->first(); $routeTestACLOpenToAll->permission()->associate($permOpenToAll); $routeTestACLOpenToAll->save(); //////////////////////////////////// // Associate some permission to flash test routes $routeFlashHome = Route::where('name', 'test-flash.home')->get()->first(); $routeFlashHome->permission()->associate($permOpenToAll); $routeFlashHome->save(); // $routeFlashSuccess = Route::where('name', 'test-flash.success')->get()->first(); $routeFlashSuccess->permission()->associate($permTestLevelSuccess); $routeFlashSuccess->save(); // $routeFlashInfo = Route::where('name', 'test-flash.info')->get()->first(); $routeFlashInfo->permission()->associate($permTestLevelInfo); $routeFlashInfo->save(); // $routeFlashWarning = Route::where('name', 'test-flash.warning')->get()->first(); $routeFlashWarning->permission()->associate($permTestLevelWarning); $routeFlashWarning->save(); // $routeFlashError = Route::where('name', 'test-flash.error')->get()->first(); $routeFlashError->permission()->associate($permTestLevelError); $routeFlashError->save(); //////////////////////////////////// // Associate some permission to menu test routes $routeTestMenusHome = Route::where('name', 'test-menus.home')->get()->first(); $routeTestMenusHome->permission()->associate($permOpenToAll); $routeTestMenusHome->save(); // $routeTestMenusOne = Route::where('name', 'test-menus.one')->get()->first(); $routeTestMenusOne->permission()->associate($permOpenToAll); $routeTestMenusOne->save(); // $routeTestMenusTwo = Route::where('name', 'test-menus.two')->get()->first(); $routeTestMenusTwo->permission()->associate($permBasicAuthenticated); $routeTestMenusTwo->save(); // $routeTestMenusTwoA = Route::where('name', 'test-menus.two-a')->get()->first(); $routeTestMenusTwoA->permission()->associate($permTestLevelSuccess); $routeTestMenusTwoA->save(); // $routeTestMenusTwoB = Route::where('name', 'test-menus.two-b')->get()->first(); $routeTestMenusTwoB->permission()->associate($permTestLevelInfo); $routeTestMenusTwoB->save(); // $routeTestMenusThree = Route::where('name', 'test-menus.three')->get()->first(); $routeTestMenusThree->permission()->associate($permTestLevelWarning); $routeTestMenusThree->save(); ///////// // Find home menu. $menuHome = Menu::where('name', 'home')->first(); ///////// // Create Test ACL menu folder $menuTestACL = Menu::create(['name' => 'test-acl.home', 'label' => 'Test ACL', 'position' => 20, 'icon' => 'fa fa-bolt', 'separator' => false, 'url' => '/test-acl/home', 'enabled' => true, 'parent_id' => $menuHome->id, 'route_id' => null, 'permission_id' => $permOpenToAll->id]); // Create DoNotPreLoad menu $menuDoNotPreLoad = Menu::create(['name' => 'test-acl.do-not-pre-load', 'label' => 'Do not pre-load', 'position' => 0, 'icon' => 'fa fa-file', 'separator' => false, 'url' => '/test-acl/do-not-pre-load', 'enabled' => true, 'parent_id' => $menuTestACL->id, 'route_id' => null, 'permission_id' => null]); // Create NoPerm menu $menuNoPerm = Menu::create(['name' => 'test-acl.no-perm', 'label' => 'No perm', 'position' => 0, 'icon' => 'fa fa-file', 'separator' => false, 'url' => '/test-acl/no-perm', 'enabled' => true, 'parent_id' => $menuTestACL->id, 'route_id' => null, 'permission_id' => null]); // Create GuestOnly menu $menuGuestOnly = Menu::create(['name' => 'test-acl.guest-only', 'label' => 'Guest Only', 'position' => 0, 'icon' => 'fa fa-file', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuTestACL->id, 'route_id' => $routeTestACLGuestOnly->id, 'permission_id' => null]); // Create OpenToAll menu $menuOpenToAll = Menu::create(['name' => 'test-acl.open-to-all', 'label' => 'Open to all', 'position' => 0, 'icon' => 'fa fa-file', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuTestACL->id, 'route_id' => $routeTestACLOpenToAll->id, 'permission_id' => null]); // Create BasicAuthenticated menu $menuBasicAuthenticated = Menu::create(['name' => 'test-acl.basic-authenticated', 'label' => 'Basic authenticated', 'position' => 0, 'icon' => 'fa fa-file', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuTestACL->id, 'route_id' => $routeTestACLBasicAuthenticated->id, 'permission_id' => null]); // Create Admins menu $menuAdmins = Menu::create(['name' => 'test-acl.admins', 'label' => 'Admins', 'position' => 0, 'icon' => 'fa fa-file', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuTestACL->id, 'route_id' => $routeTestACLAdmins->id, 'permission_id' => null]); // Create PowerUsers menu $menuPowerUsers = Menu::create(['name' => 'test-acl.power-users', 'label' => 'Power users', 'position' => 0, 'icon' => 'fa fa-file', 'separator' => false, 'url' => '/test-acl/power-users', 'enabled' => true, 'parent_id' => $menuTestACL->id, 'route_id' => null, 'permission_id' => null]); ///////// // Create Test flash menu folder $menuTestFlashHome = Menu::create(['name' => 'test-flash.home', 'label' => 'Test Flash', 'position' => 20, 'icon' => 'fa fa-bolt', 'separator' => false, 'url' => '/test-flash/home', 'enabled' => true, 'parent_id' => $menuHome->id, 'route_id' => null, 'permission_id' => $permBasicAuthenticated->id]); // Create Flash success menu $menuFlashSuccess = Menu::create(['name' => 'test-flash.success', 'label' => 'Flash success', 'position' => 0, 'icon' => 'fa fa-check fa-colour-green', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuTestFlashHome->id, 'route_id' => $routeFlashSuccess->id, 'permission_id' => null]); // Create Flash info menu $menuFlashInfo = Menu::create(['name' => 'test-flash.info', 'label' => 'Flash info', 'position' => 10, 'icon' => 'fa fa-info fa-colour-blue', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuTestFlashHome->id, 'route_id' => $routeFlashInfo->id, 'permission_id' => null]); // Create Flash warning menu $menuFlashWarning = Menu::create(['name' => 'test-flash.warning', 'label' => 'Flash warning', 'position' => 20, 'icon' => 'fa fa-warning fa-colour-orange', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuTestFlashHome->id, 'route_id' => $routeFlashWarning->id, 'permission_id' => null]); // Create Flash error menu $menuFlashError = Menu::create(['name' => 'test-flash.error', 'label' => 'Flash error', 'position' => 30, 'icon' => 'fa fa-ban fa-colour-red', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuTestFlashHome->id, 'route_id' => $routeFlashError->id, 'permission_id' => null]); ///////// // Create Test menu folder $menuTestMenusHome = Menu::create(['name' => 'test-menus.home', 'label' => 'Test Menus', 'position' => 30, 'icon' => 'fa fa-bolt', 'separator' => false, 'url' => '/test-menus/home', 'enabled' => true, 'parent_id' => $menuHome->id, 'route_id' => null, 'permission_id' => $permOpenToAll->id]); // Create Menu 1 menu $menuTestMenusOne = Menu::create(['name' => 'test-menus.one', 'label' => 'Menu One', 'position' => 0, 'icon' => 'fa fa-bars', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuTestMenusHome->id, 'route_id' => $routeTestMenusOne->id, 'permission_id' => null]); // Create Menu 2 menu $menuTestMenusTwo = Menu::create(['name' => 'test-menus.two', 'label' => 'Menu Two', 'position' => 10, 'icon' => 'fa fa-bars', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuTestMenusHome->id, 'route_id' => $routeTestMenusTwo->id, 'permission_id' => null]); // Create Menu 2a menu $menuTestMenusTwo2a = Menu::create(['name' => 'test-menus.two-a', 'label' => 'Menu Two A', 'position' => 0, 'icon' => 'fa fa-bars', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuTestMenusTwo->id, 'route_id' => $routeTestMenusTwoA->id, 'permission_id' => null]); // Create Menu 2b menu $menuTestMenusTwo2b = Menu::create(['name' => 'test-menus.two-b', 'label' => 'Menu Two B', 'position' => 10, 'icon' => 'fa fa-bars', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuTestMenusTwo->id, 'route_id' => $routeTestMenusTwoB->id, 'permission_id' => null]); // Create Menu 2a alias by URL $menuTestMenusTwo2a = Menu::create(['name' => 'test-menus.two-a-alias-url', 'label' => 'Menu Two A alias by URL', 'position' => 0, 'icon' => 'fa fa-bars', 'separator' => false, 'url' => '/test-menus/two-a', 'enabled' => true, 'parent_id' => $menuTestMenusTwo->id, 'route_id' => null, 'permission_id' => $permBasicAuthenticated->id]); // Create Menu 2a alias by ROUTE $menuTestMenusTwo2a = Menu::create(['name' => 'test-menus.two-a-alias-route', 'label' => 'Menu Two A alias by route', 'position' => 0, 'icon' => 'fa fa-bars', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuTestMenusTwo->id, 'route_id' => Route::where('name', 'like', "test-menus.two_a")->get()->first()->id, 'permission_id' => null]); // Create Menu 3 menu $menuTestMenusTwo3 = Menu::create(['name' => 'test-menus.three', 'label' => 'Menu Three', 'position' => 20, 'icon' => 'fa fa-bars', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuTestMenusHome->id, 'route_id' => $routeTestMenusThree->id, 'permission_id' => null]); }
public function getRequests($id) { return Response::json(DbUtil::serializeRoutes(Route::where('state', 'requested')->where('ride_id', $id)->get())); }
/** * Run the database seeds. * * @return void */ public function run() { //////////////////////////////////// // Load the routes Route::loadLaravelRoutes(); // Look for and delete route named 'do-not-load' if it exist. // That route is used to test the Authorization middleware and should not be loaded automatically. $routeToDelete = Route::where('name', 'do-not-load')->get()->first(); if ($routeToDelete) { Route::destroy($routeToDelete->id); } //////////////////////////////////// // Create basic set of permissions $permGuestOnly = Permission::create(['name' => 'guest-only', 'display_name' => 'Guest only access', 'description' => 'Only guest users can access these.', 'enabled' => true]); $permOpenToAll = Permission::create(['name' => 'open-to-all', 'display_name' => 'Open to all', 'description' => 'Everyone can access these, even unauthenticated (guest) users.', 'enabled' => true]); $permBasicAuthenticated = Permission::create(['name' => 'basic-authenticated', 'display_name' => 'Basic authenticated', 'description' => 'Basic permission after being authenticated.', 'enabled' => true]); // Create a few permissions for the admin|security section $permManageMenus = Permission::create(['name' => 'manage-menus', 'display_name' => 'Manage menus', 'description' => 'Allows a user to manage the site menus.', 'enabled' => true]); $permManageUsers = Permission::create(['name' => 'manage-users', 'display_name' => 'Manage users', 'description' => 'Allows a user to manage the site users.', 'enabled' => true]); $permManageRoles = Permission::create(['name' => 'manage-roles', 'display_name' => 'Manage roles', 'description' => 'Allows a user to manage the site roles.', 'enabled' => true]); $permManagePermissions = Permission::create(['name' => 'manage-permissions', 'display_name' => 'Manage permissions', 'description' => 'Allows a user to manage the site permissions.', 'enabled' => true]); $permManageRoutes = Permission::create(['name' => 'manage-routes', 'display_name' => 'Manage routes', 'description' => 'Allows a user to Manage the site routes.', 'enabled' => true]); // Create a few permissions for the admin|audit section $permAuditLogView = Permission::create(['name' => 'audit-log-view', 'display_name' => 'View audit log', 'description' => 'Allows a user to view the audit log.', 'enabled' => true]); $permAuditReplay = Permission::create(['name' => 'audit-log-replay', 'display_name' => 'Replay audit log item', 'description' => 'Allows a user to replay items from the audit log.', 'enabled' => true]); $permAuditPurge = Permission::create(['name' => 'audit-log-purge', 'display_name' => 'Purge audit log', 'description' => 'Allows a user to purge old items from the audit log.', 'enabled' => true]); $permAdminSettings = Permission::create(['name' => 'admin-settings', 'display_name' => 'Administer site settings', 'description' => 'Allows a user to change site settings.', 'enabled' => true]); //////////////////////////////////// // Associate open-to-all permission to some routes $routeBackslash = Route::where('name', 'backslash')->get()->first(); $routeBackslash->permission()->associate($permOpenToAll); $routeBackslash->save(); $routeHome = Route::where('name', 'home')->get()->first(); $routeHome->permission()->associate($permOpenToAll); $routeHome->save(); $routeFaust = Route::where('name', 'faust')->get()->first(); $routeFaust->permission()->associate($permOpenToAll); $routeFaust->save(); // Associate basic-authenticated permission to the dashboard route $routeDashboard = Route::where('name', 'dashboard')->get()->first(); $routeDashboard->permission()->associate($permBasicAuthenticated); $routeDashboard->save(); // Associate the audit-log permissions $routeAuditView = Route::where('name', 'admin.audit.index')->get()->first(); $routeAuditView->permission()->associate($permAuditLogView); $routeAuditView->save(); $routeAuditShow = Route::where('name', 'admin.audit.show')->get()->first(); $routeAuditShow->permission()->associate($permAuditLogView); $routeAuditShow->save(); $routeAuditPurge = Route::where('name', 'admin.audit.purge')->get()->first(); $routeAuditPurge->permission()->associate($permAuditPurge); $routeAuditPurge->save(); $routeAuditReplay = Route::where('name', 'admin.audit.replay')->get()->first(); $routeAuditReplay->permission()->associate($permAuditReplay); $routeAuditReplay->save(); // Associate manage-menus permissions to routes starting with 'admin.menus.' $manageMenusRoutes = Route::where('name', 'like', "admin.menus.%")->get()->all(); foreach ($manageMenusRoutes as $route) { $route->permission()->associate($permManageMenus); $route->save(); } // Associate manage-permission permissions to routes starting with 'admin.permissions.' $managePermRoutes = Route::where('name', 'like', "admin.permissions.%")->get()->all(); foreach ($managePermRoutes as $route) { $route->permission()->associate($permManagePermissions); $route->save(); } // Associate manage-roles permissions to routes starting with 'admin.roles.' $manageRoleRoutes = Route::where('name', 'like', "admin.roles.%")->get()->all(); foreach ($manageRoleRoutes as $route) { $route->permission()->associate($permManageRoles); $route->save(); } // Associate manage-routes permissions to routes starting with 'admin.routes.' $manageRouteRoutes = Route::where('name', 'like', "admin.routes.%")->get()->all(); foreach ($manageRouteRoutes as $route) { $route->permission()->associate($permManageRoutes); $route->save(); } // Associate manage-users permissions to routes starting with 'admin.users.' $manageUserRoutes = Route::where('name', 'like', "admin.users.%")->get()->all(); foreach ($manageUserRoutes as $route) { $route->permission()->associate($permManageUsers); $route->save(); } // Associate the admin-settings permissions $routeAdminSettings = Route::where('name', 'admin.settings.index')->get()->first(); $routeAdminSettings->permission()->associate($permAdminSettings); $routeAdminSettings->save(); //////////////////////////////////// // Create role: admins $roleAdmins = Role::create(["name" => "admins", "display_name" => "Administrators", "description" => "Administrators have no restrictions", "enabled" => true]); // Create role: users // Assign permission basic-authenticated $roleUsers = Role::create(["name" => "users", "display_name" => "Users", "description" => "All authenticated users", "enabled" => true]); $roleUsers->perms()->attach($permBasicAuthenticated->id); // Create role: menu-manager // Assign permission manage-menus $roleMenuManagers = Role::create(["name" => "menu-managers", "display_name" => "Menu managers", "description" => "Menu managers are granted all permissions to the Admin|Menus section.", "enabled" => true]); $roleMenuManagers->perms()->attach($permManageMenus->id); // Create role: user-manager // Assign permission manage-users $roleUserManagers = Role::create(["name" => "user-managers", "display_name" => "User managers", "description" => "User managers are granted all permissions to the Admin|Users section.", "enabled" => true]); $roleUserManagers->perms()->attach($permManageUsers->id); // Create role: role-manager // Assign permission: manage-roles $roleRoleManagers = Role::create(["name" => "role-managers", "display_name" => "Role managers", "description" => "Role managers are granted all permissions to the Admin|Roles section.", "enabled" => true]); $roleRoleManagers->perms()->attach($permManageRoles->id); // Create role: audit-viewers // Assign permission: audit-log-view $roleAuditViewers = Role::create(["name" => "audit-viewers", "display_name" => "Audit viewers", "description" => "Users allowed to view the audit log.", "enabled" => true]); $roleAuditViewers->perms()->attach($permAuditLogView->id); // Create role: audit-replayers // Assign permission: audit-log-replay $roleAuditReplayers = Role::create(["name" => "audit-replayers", "display_name" => "Audit replayers", "description" => "Users allowed to replay items from the audit log.", "enabled" => true]); $roleAuditReplayers->perms()->attach($permAuditReplay->id); // Create role: audit-purgers // Assign permission: audit-log-purge $roleAuditPurgers = Role::create(["name" => "audit-purgers", "display_name" => "Audit purgers", "description" => "Users allowed to purge old items from the audit log.", "enabled" => true]); $roleAuditPurgers->perms()->attach($permAuditPurge->id); //////////////////////////////////// // Create user: root // Assign membership to role admins, membership to role users is // automatic. $userRoot = User::create(["first_name" => "Root", "last_name" => "SuperUser", "username" => "root", "email" => "*****@*****.**", "password" => "Password1", "auth_type" => "internal", "enabled" => true]); $userRoot->roles()->attach($roleAdmins->id); //////////////////////////////////// // Create menu: root $menuRoot = Menu::create(['name' => 'root', 'label' => 'Root', 'position' => 0, 'icon' => 'fa fa-folder', 'separator' => false, 'url' => null, 'enabled' => true, 'route_id' => null, 'permission_id' => $permOpenToAll->id]); // Force root parent to itself. $menuRoot->parent_id = $menuRoot->id; $menuRoot->save(); // Create Home menu $menuHome = Menu::create(['name' => 'home', 'label' => 'Home', 'position' => 0, 'icon' => 'fa fa-home fa-colour-green', 'separator' => false, 'url' => '/', 'enabled' => true, 'parent_id' => $menuRoot->id, 'route_id' => $routeHome->id, 'permission_id' => null]); // Create Dashboard menu $menuDashboard = Menu::create(['name' => 'dashboard', 'label' => 'Dashboard', 'position' => 0, 'icon' => 'fa fa-dashboard', 'separator' => false, 'url' => '/dashboard', 'enabled' => true, 'parent_id' => $menuHome->id, 'route_id' => $routeDashboard->id, 'permission_id' => null]); // Create Admin container. $menuAdmin = Menu::create(['name' => 'admin', 'label' => 'Admin', 'position' => 999, 'icon' => 'fa fa-cog', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuRoot->id, 'route_id' => null, 'permission_id' => null]); // Create Audit sub-menu $menuAudit = Menu::create(['name' => 'audit', 'label' => 'Audit', 'position' => 0, 'icon' => 'fa fa-binoculars', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuAdmin->id, 'route_id' => $routeAuditView->id, 'permission_id' => null]); // Create Security container. $menuSecurity = Menu::create(['name' => 'security', 'label' => 'Security', 'position' => 1, 'icon' => 'fa fa-user-secret fa-colour-red', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuAdmin->id, 'route_id' => null, 'permission_id' => null]); // Create Menus sub-menu $menuMenus = Menu::create(['name' => 'menus', 'label' => 'Menus', 'position' => 0, 'icon' => 'fa fa-bars', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuSecurity->id, 'route_id' => Route::where('name', 'like', "admin.menus.index")->get()->first()->id, 'permission_id' => null]); // Create separator $menuUsers = Menu::create(['name' => 'menus-users-separator', 'label' => '-----', 'position' => 1, 'icon' => null, 'separator' => true, 'url' => null, 'enabled' => true, 'parent_id' => $menuSecurity->id, 'route_id' => null, 'permission_id' => null]); // Create Users sub-menu $menuUsers = Menu::create(['name' => 'users', 'label' => 'Users', 'position' => 2, 'icon' => 'fa fa-user', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuSecurity->id, 'route_id' => Route::where('name', 'like', "admin.users.index")->get()->first()->id, 'permission_id' => null]); // Create Roles sub-menu $menuRoles = Menu::create(['name' => 'roles', 'label' => 'Roles', 'position' => 3, 'icon' => 'fa fa-users', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuSecurity->id, 'route_id' => Route::where('name', 'like', "admin.roles.index")->get()->first()->id, 'permission_id' => null]); // Create Permissions sub-menu $menuPermissions = Menu::create(['name' => 'permissions', 'label' => 'Permissions', 'position' => 4, 'icon' => 'fa fa-bolt', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuSecurity->id, 'route_id' => Route::where('name', 'like', "admin.permissions.index")->get()->first()->id, 'permission_id' => null]); // Create Routes sub-menu $menuRoutes = Menu::create(['name' => 'routes', 'label' => 'Routes', 'position' => 5, 'icon' => 'fa fa-road', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuSecurity->id, 'route_id' => Route::where('name', 'like', "admin.routes.index")->get()->first()->id, 'permission_id' => null]); // Create Settings sub-menu $menuSettings = Menu::create(['name' => 'setting', 'label' => 'Settings', 'position' => 2, 'icon' => 'fa fa-cogs', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuAdmin->id, 'route_id' => $routeAdminSettings->id, 'permission_id' => null]); }
public function getLeafMenuItem(Menu $leaf = null) { // Get the leaf menu item from the value passed in. try { $leaf = $this->traitGetLeafMenuItem($leaf); return $leaf; } catch (MenuBuilderMenuItemNotFoundException $ex) { // Eat the exception as we want a chance to find it from the current route. } // if the leaf node was not found from the passed in value, try to get it from the current route. $routeLaravel = $this->app->request->route(); $routeAction = $routeLaravel->getAction(); $routeName = $routeAction['as']; $routeL51esk = Route::where('name', $routeName)->first(); if ($routeL51esk instanceof Route) { $leaf = $this->menuRepository->findBy('route_id', $routeL51esk->id); if ($leaf instanceof Menu) { return $leaf; } } // Could not find the requested menu item, throwing an exception. throw new MenuBuilderMenuItemNotFoundException("Menu item [" . $leaf . "] not found for URL [" . $routeName . "]."); }
/** * Locate module routes, dissociate from perms and delete * * @param $string */ protected static function destroyRoute($name) { $routeShow = Route::where('name', $name)->first(); if ($routeShow) { $routeShow->permission()->dissociate(); Route::destroy($routeShow->id); } }
/** * Run the database seeds. * * @return void */ public function run() { //////////////////////////////////// // Load the routes Route::loadLaravelRoutes(); // Look for and delete route named 'do-not-load' if it exist. // That route is used to test the Authorization middleware and should not be loaded automatically. $routeToDelete = Route::where('name', 'do-not-load')->get()->first(); if ($routeToDelete) { Route::destroy($routeToDelete->id); } //////////////////////////////////// // Create basic set of permissions $permGuestOnly = Permission::create(['name' => 'guest-only', 'display_name' => 'Guest only access', 'description' => 'Only guest users can access these.', 'enabled' => true]); $permOpenToAll = Permission::create(['name' => 'open-to-all', 'display_name' => 'Open to all', 'description' => 'Everyone can access these, even unauthenticated (guest) users.', 'enabled' => true]); $permBasicAuthenticated = Permission::create(['name' => 'basic-authenticated', 'display_name' => 'Basic authenticated', 'description' => 'Basic permission after being authenticated.', 'enabled' => true]); // Create a few permissions for the admin|security section $permManageUsers = Permission::create(['name' => 'manage-users', 'display_name' => 'Manage users', 'description' => 'Allows a user to manage the site users.', 'enabled' => true]); $permManageRoles = Permission::create(['name' => 'manage-roles', 'display_name' => 'Manage roles', 'description' => 'Allows a user to manage the site roles.', 'enabled' => true]); $permManagePermissions = Permission::create(['name' => 'manage-permissions', 'display_name' => 'Manage permissions', 'description' => 'Allows a user to manage the site permissions.', 'enabled' => true]); $permManageRoutes = Permission::create(['name' => 'manage-routes', 'display_name' => 'Manage routes', 'description' => 'Allows a user to Manage the site routes.', 'enabled' => true]); // Create a few permissions for the admin|audit section $permAuditLogView = Permission::create(['name' => 'audit-log-view', 'display_name' => 'View audit log', 'description' => 'Allows a user to view the audit log.', 'enabled' => true]); $permAuditReplay = Permission::create(['name' => 'audit-log-replay', 'display_name' => 'Replay audit log item', 'description' => 'Allows a user to replay items from the audit log.', 'enabled' => true]); $permAuditPurge = Permission::create(['name' => 'audit-log-purge', 'display_name' => 'Purge audit log', 'description' => 'Allows a user to purge old items from the audit log.', 'enabled' => true]); // Create permission for managing CUCM Clusters $permManageClusters = Permission::create(['name' => 'manage-clusters', 'display_name' => 'Manage clusters', 'description' => 'Allows a user to manage CUCM cluster settings.', 'enabled' => true]); // Create permission for erasing IP Phone certificates $permEraseCertificates = Permission::create(['name' => 'erase-certificates', 'display_name' => 'Erase Certificates', 'description' => 'Allows a user to eraser IP Phone security certificates.', 'enabled' => true]); // Create permission for running SQL queries $permRunSqlQuery = Permission::create(['name' => 'sql-run', 'display_name' => 'Run SQL Queries', 'description' => 'Allows a user to run pre-existing queries against the active CUCM cluster.', 'enabled' => true]); // Create permission for running new SQL queries $permAddSqlQuery = Permission::create(['name' => 'sql-add', 'display_name' => 'Add SQL Queries', 'description' => 'Allows a user to run new SQL queries against the active CUCM cluster.', 'enabled' => true]); // Create permission for deleting SQL queries $permDeleteSqlQuery = Permission::create(['name' => 'sql-delete', 'display_name' => 'Delete SQL Queries', 'description' => 'Allows a user to delete existing SQL queries.', 'enabled' => true]); // Create permission for deleting SQL queries $permAutoDialer = Permission::create(['name' => 'autodialer', 'display_name' => 'AutoDialer', 'description' => 'Allows a user to place calls using AutoDialer.', 'enabled' => true]); // Create permission for generating IOS configs $permJfsUser = Permission::create(['name' => 'jfs-user', 'display_name' => 'JFS R/O', 'description' => 'Allows a user to view JFS features.', 'enabled' => true]); // Create permission for generating IOS configs $permJfsAdmin = Permission::create(['name' => 'jfs-admin', 'display_name' => 'Manage all things JFS', 'description' => 'Allows a user to manage the JFS features.', 'enabled' => true]); // Create permission for managing Duo Users $permManageDuoUsers = Permission::create(['name' => 'duo-users-admin', 'display_name' => 'Manage Duo Users', 'description' => 'Allows a user to manage the Duo user accounts.', 'enabled' => true]); //////////////////////////////////// // Associate open-to-all permission to some routes $routeBackslash = Route::where('name', 'backslash')->get()->first(); $routeBackslash->permission()->associate($permOpenToAll); $routeBackslash->save(); $routeHome = Route::where('name', 'home')->get()->first(); $routeHome->permission()->associate($permOpenToAll); $routeHome->save(); $routeFaust = Route::where('name', 'faust')->get()->first(); $routeFaust->permission()->associate($permOpenToAll); $routeFaust->save(); // Associate basic-authenticated permission to the dashboard route $routeDashboard = Route::where('name', 'dashboard')->get()->first(); $routeDashboard->permission()->associate($permBasicAuthenticated); $routeDashboard->save(); // Associate the audit-log permissions $routeAuditView = Route::where('name', 'admin.audit.index')->get()->first(); $routeAuditView->permission()->associate($permAuditLogView); $routeAuditView->save(); $routeAuditPurge = Route::where('name', 'admin.audit.purge')->get()->first(); $routeAuditPurge->permission()->associate($permAuditPurge); $routeAuditPurge->save(); $routeAuditReplay = Route::where('name', 'admin.audit.replay')->get()->first(); $routeAuditReplay->permission()->associate($permAuditReplay); $routeAuditReplay->save(); // Associate manage-permission permissions to routes starting with 'admin.permissions.' $managePermRoutes = Route::where('name', 'like', "admin.permissions.%")->get()->all(); foreach ($managePermRoutes as $route) { $route->permission()->associate($permManagePermissions); $route->save(); } // Associate manage-roles permissions to routes starting with 'admin.roles.' $manageRoleRoutes = Route::where('name', 'like', "admin.roles.%")->get()->all(); foreach ($manageRoleRoutes as $route) { $route->permission()->associate($permManageRoles); $route->save(); } // Associate manage-routes permissions to routes starting with 'admin.routes.' $manageRouteRoutes = Route::where('name', 'like', "admin.routes.%")->get()->all(); foreach ($manageRouteRoutes as $route) { $route->permission()->associate($permManageRoutes); $route->save(); } // Associate manage-users permissions to routes starting with 'admin.users.' $manageUserRoutes = Route::where('name', 'like', "admin.users.%")->get()->all(); foreach ($manageUserRoutes as $route) { $route->permission()->associate($permManageUsers); $route->save(); } //////////////////////////////////// // Create role: admins $roleAdmins = Role::create(["name" => "admins", "display_name" => "Administrators", "description" => "Administrators have no restrictions", "enabled" => true]); // Create role: users // Assign permission basic-authenticated $roleUsers = Role::create(["name" => "users", "display_name" => "Users", "description" => "All authenticated users", "enabled" => true]); $roleUsers->perms()->attach($permBasicAuthenticated->id); // Create role: user-manager // Assign permission manage-users $roleUserManagers = Role::create(["name" => "user-managers", "display_name" => "User managers", "description" => "User managers are granted all permissions to the Admin|Users section.", "enabled" => true]); $roleUserManagers->perms()->attach($permManageUsers->id); // Create role: role-manager // Assign permission: manage-roles $roleRoleManagers = Role::create(["name" => "role-managers", "display_name" => "Role managers", "description" => "Role managers are granted all permissions to the Admin|Roles section.", "enabled" => true]); $roleRoleManagers->perms()->attach($permManageRoles->id); // Create role: audit-viewers // Assign permission: audit-log-view $roleAuditViewers = Role::create(["name" => "audit-viewers", "display_name" => "Audit viewers", "description" => "Users allowed to view the audit log.", "enabled" => true]); $roleAuditViewers->perms()->attach($permAuditLogView->id); // Create role: audit-replayers // Assign permission: audit-log-replay $roleAuditReplayers = Role::create(["name" => "audit-replayers", "display_name" => "Audit replayers", "description" => "Users allowed to replay items from the audit log.", "enabled" => true]); $roleAuditReplayers->perms()->attach($permAuditReplay->id); // Create role: audit-purgers // Assign permission: audit-log-purge $roleAuditPurgers = Role::create(["name" => "audit-purgers", "display_name" => "Audit purgers", "description" => "Users allowed to purge old items from the audit log.", "enabled" => true]); $roleAuditPurgers->perms()->attach($permAuditPurge->id); // Create role: cluster-managers // Assign permission: permManageClusters $roleClusterManagers = Role::create(["name" => "cluster-managers", "display_name" => "Cluster managers", "description" => "Cluster managers are granted all permissions to the Admin|Clusters section.", "enabled" => true]); $roleClusterManagers->perms()->attach($permManageClusters->id); // Create role: cert-erasers // Assign permission: permManageClusters $roleCertErasers = Role::create(["name" => "cert-erasers", "display_name" => "Certificate erasers", "description" => "Certificate erasers are granted permissions to erase IP Phone security certificates.", "enabled" => true]); $roleCertErasers->perms()->attach($permEraseCertificates->id); // Create role: sql-runner // Assign permission: permRunSqlQuery $roleSqlRunner = Role::create(["name" => "sql-runner", "display_name" => "SQL Runner", "description" => "SQL Runners can run existing queries against the active CUCM cluster.", "enabled" => true]); $roleSqlRunner->perms()->attach($permRunSqlQuery->id); // Create role: sql-creator // Assign permission: permRunSqlQuery // Assign permission: permAddSqlQuery $roleSqlCreator = Role::create(["name" => "sql-creator", "display_name" => "SQL Creator", "description" => "SQL Creators can run new and existing queries against the active CUCM cluster.", "enabled" => true]); $roleSqlCreator->perms()->attach($permRunSqlQuery->id); $roleSqlCreator->perms()->attach($permAddSqlQuery->id); // Create role: sql-admin // Assign permission: permRunSqlQuery // Assign permission: permAddSqlQuery // Assign permission: permDeleteSqlQuery $roleSqlAdmin = Role::create(["name" => "sql-admin", "display_name" => "SQL Admin", "description" => "SQL Admins can run new and existing queries against the active CUCM cluster and delete queries.", "enabled" => true]); $roleSqlAdmin->perms()->attach($permRunSqlQuery->id); $roleSqlAdmin->perms()->attach($permAddSqlQuery->id); $roleSqlAdmin->perms()->attach($permDeleteSqlQuery->id); // Create role: autodialer // Assign permission: permAutoDialer $roleAutoDialer = Role::create(["name" => "autodialer", "display_name" => "AutoDialer", "description" => "AutoDialer can use the AutoDialer system.", "enabled" => true]); $roleAutoDialer->perms()->attach($permAutoDialer->id); // Create role: ios-config-user // Assign permission: permAutoDialer $roleJfsUser = Role::create(["name" => "jfs-user", "display_name" => "JFS User", "description" => "JFS Users can view JFS features.", "enabled" => true]); $roleJfsUser->perms()->attach($permJfsUser->id); // Create role: ios-config-admin // Assign permission: permAutoDialer $roleJfsAdmin = Role::create(["name" => "jfs-admin", "display_name" => "JFS Admin", "description" => "JFS Admins manage the JFS features.", "enabled" => true]); $roleJfsAdmin->perms()->attach($permJfsAdmin->id); // Create role: duo-user-admin // Assign permission: permManageDuoUsers $roleDuoUserAdmin = Role::create(["name" => "duo-user-admin", "display_name" => "Duo User Admin", "description" => "Duo User Admins manage the Duo User accounts.", "enabled" => true]); $roleDuoUserAdmin->perms()->attach($permManageDuoUsers->id); //////////////////////////////////// // Create user: root // Assign membership to role admins, membership to role users is // automatic. $userRoot = User::create(["first_name" => "Root", "last_name" => "SuperUser", "username" => "root", "email" => "*****@*****.**", "password" => "Password1", "auth_type" => "internal", "enabled" => true]); $userRoot->roles()->attach($roleAdmins->id); $department = \App\Models\Department::first(); $department->users()->save($userRoot); }
public function getRequests() { return Response::json(DbUtil::serializeRoutes(Route::where('user_id', Auth::user()->id)->where('state', 'requested')->get())); }