/**
  * @return \Illuminate\Http\JsonResponse
  */
 public function createPermission($name, $permissions, $desc)
 {
     $permission = new Permission();
     $attr = json_decode($permissions);
     $myPermission = $permission->create(['name' => $name, 'slug' => ['create' => $attr[0] == null ? false : $attr[0], 'view' => $attr[1] == null ? false : $attr[1], 'update' => $attr[2] == null ? false : $attr[2], 'delete' => $attr[3] == null ? false : $attr[3]], 'description' => strlen($desc) > 0 ? $desc : "No Description Available..."]);
     $permission->save();
     $status = array();
     $status['result'] = "success";
     return response()->json($status);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     if (App::environment() === 'production') {
         exit('Seed should be run only in development/debug environment.');
     }
     DB::statement('SET FOREIGN_KEY_CHECKS=0');
     DB::table('permissions')->truncate();
     $permission = new Permission();
     $permUser = $permission->create(['name' => 'users', 'slug' => ['create' => true, 'view' => true, 'update' => true, 'delete' => true], 'description' => 'manage user permissions']);
     $permission = new Permission();
     $permUser = $permission->create(['name' => 'events', 'slug' => ['create' => true, 'view' => true, 'update' => true, 'delete' => true], 'description' => 'manage event permissions']);
     $permission = new Permission();
     $permUser = $permission->create(['name' => 'organizations', 'slug' => ['create' => true, 'view' => true, 'update' => true, 'delete' => true], 'description' => 'manage organization permissions']);
     $permission = new Permission();
     $permUser = $permission->create(['name' => 'attendees', 'slug' => ['create' => true, 'view' => true, 'update' => true, 'delete' => true], 'description' => 'manage attendee permissions']);
     DB::statement('SET FOREIGN_KEY_CHECKS=1');
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $permission = new Permission();
     $permission->create(['name' => 'user', 'slug' => ['create' => true, 'view' => true, 'update' => true, 'delete' => true], 'description' => 'manage user permissions']);
     $permission->create(['name' => 'goal', 'slug' => ['create' => true, 'view' => true, 'update' => true, 'delete' => true], 'description' => 'manage goal permissions']);
     $permission->create(['name' => 'objective', 'slug' => ['create' => true, 'view' => true, 'update' => true, 'delete' => true], 'description' => 'manage objective permissions']);
     $permission->create(['name' => 'action', 'slug' => ['create' => true, 'view' => true, 'update' => true, 'delete' => true], 'description' => 'manage action permissions']);
     $permission->create(['name' => 'task', 'slug' => ['create' => true, 'view' => true, 'update' => true, 'delete' => true], 'description' => 'manage task permissions']);
     $permission->create(['name' => 'mywork', 'slug' => ['create' => true, 'view' => true, 'update' => true, 'delete' => true], 'description' => 'manage myWork permissions']);
     $permission->create(['name' => 'register', 'slug' => ['create' => true, 'view' => true, 'update' => true, 'delete' => true], 'description' => 'manage register permissions']);
 }
 public function run()
 {
     Permission::orderBy('inherit_id', 'desc')->delete();
     // project
     $permission = new Permission();
     $permissionProject = $permission->create(['name' => 'project', 'slug' => ['create' => true, 'view' => true, 'update' => true, 'delete' => true], 'description' => 'Manage project permissions.']);
     $permission = new Permission();
     $permissionProjectModerator = $permission->create(['name' => 'project.moderator', 'slug' => ['create' => false, 'update' => false, 'delete' => false], 'inherit_id' => $permissionProject->getKey(), 'description' => 'Moderator project permissions.']);
     // deployment
     $permission = new Permission();
     $permissionDeployment = $permission->create(['name' => 'deployment', 'slug' => ['create' => true, 'view' => true, 'update' => true, 'delete' => true], 'description' => 'Manage deployment permissions.']);
     // recipe
     $permission = new Permission();
     $permissionRecipe = $permission->create(['name' => 'recipe', 'slug' => ['create' => true, 'view' => true, 'update' => true, 'delete' => true], 'description' => 'Manage recipe permissions.']);
     $permission = new Permission();
     $permissionRecipeModerator = $permission->create(['name' => 'recipe.moderator', 'slug' => ['create' => false, 'update' => false, 'delete' => false], 'inherit_id' => $permissionRecipe->getKey(), 'description' => 'Moderator recipe permissions.']);
     // server
     $permission = new Permission();
     $permissionServer = $permission->create(['name' => 'server', 'slug' => ['create' => true, 'view' => true, 'update' => true, 'delete' => true], 'description' => 'Manage server permissions.']);
     $permission = new Permission();
     $permissionServerModerator = $permission->create(['name' => 'server.moderator', 'slug' => ['create' => false, 'update' => false, 'delete' => false], 'inherit_id' => $permissionServer->getKey(), 'description' => 'Moderator server permissions.']);
     // user
     $permission = new Permission();
     $permissionUser = $permission->create(['name' => 'user', 'slug' => ['create' => true, 'view' => true, 'update' => true, 'delete' => true], 'description' => 'Manage user permissions.']);
     $permission = new Permission();
     $permissionUserDeveloper = $permission->create(['name' => 'user.developer', 'slug' => ['create' => false, 'view' => false, 'update' => false, 'delete' => false], 'inherit_id' => $permissionUser->getKey(), 'description' => 'Developer user permissions.']);
     $permission = new Permission();
     $permissionUserModerator = $permission->create(['name' => 'user.moderator', 'slug' => ['create' => false, 'view' => false, 'update' => false, 'delete' => false], 'inherit_id' => $permissionUser->getKey(), 'description' => 'Moderator user permissions.']);
     // setting
     $permission = new Permission();
     $permissionSetting = $permission->create(['name' => 'setting', 'slug' => ['create' => true, 'view' => true, 'update' => true, 'delete' => true], 'description' => 'Manage setting permissions.']);
     $permission = new Permission();
     $permissionSettingDeveloper = $permission->create(['name' => 'setting.developer', 'slug' => ['create' => false, 'view' => false, 'update' => false, 'delete' => false], 'inherit_id' => $permissionSetting->getKey(), 'description' => 'Developer setting permissions.']);
     $permission = new Permission();
     $permissionSettingModerator = $permission->create(['name' => 'setting.moderator', 'slug' => ['create' => false, 'view' => false, 'update' => false, 'delete' => false], 'inherit_id' => $permissionSetting->getKey(), 'description' => 'Moderator setting permissions.']);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $roles = Role::all();
     $permissions = Permission::all();
     foreach ($permissions as $permission) {
         foreach ($roles as $role) {
             $next = $role->id . '-' . $permission->id;
             if (Input::get($next)) {
                 $role->assignPermission($permission);
             } else {
                 $role->revokePermission($permission);
             }
         }
     }
     return Redirect::to('/admin/access');
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $role = new Role();
     $roleAdmin = $role->create(['name' => 'Admin', 'slug' => 'admin', 'description' => 'Manage Administration privileges']);
     $roleAdmin->assignPermission(Permission::all());
     $rolebpLead = $role->create(['name' => 'BPLead', 'slug' => 'bplead', 'description' => 'Manage Business Plan privileges']);
     $rolebpLead->assignPermission('mywork');
     $roledepLead = $role->create(['name' => 'DepLead', 'slug' => 'deplead', 'description' => 'Manage Department Lead privileges']);
     $roledepLead->assignPermission('objective');
     $roledepLead->assignPermission('mywork');
     $roleteamLead = $role->create(['name' => 'TeamLead', 'slug' => 'teamlead', 'description' => 'Manage Team Lead privileges']);
     $roleteamLead->assignPermission('action');
     $roleteamLead->assignPermission('mywork');
     $rolebasicUser = $role->create(['name' => 'BasicUser', 'slug' => 'basicuser', 'description' => 'Manage Basic User privileges']);
     $rolebasicUser->assignPermission('mywork');
     $rolebasicUser->assignPermission('action');
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     \DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     \DB::table('permissions')->delete();
     \DB::statement('SET FOREIGN_KEY_CHECKS=1;');
     $userPermission = Permission::create(['name' => 'user', 'slug' => ['index' => true, 'store' => true, 'show' => true, 'update' => true, 'destroy' => true], 'description' => 'user']);
     $userPermissionForUser = Permission::create(['name' => 'user.user', 'slug' => ['index' => false, 'store' => false, 'destroy' => false], 'inherit_id' => $userPermission->getKey(), 'description' => 'user']);
     $exercisePermission = Permission::create(['name' => 'exercise', 'slug' => ['index' => true, 'store' => true, 'show' => true, 'update' => true, 'destroy' => true], 'description' => 'exercise']);
     $exerciseTranslationPermission = Permission::create(['name' => 'exercise_translation', 'slug' => ['index' => true, 'store' => true, 'destroy' => true], 'description' => 'exercise_translation']);
     $wordPermission = Permission::create(['name' => 'word', 'slug' => ['index' => true, 'store' => true, 'show' => true, 'update' => true, 'destroy' => true], 'description' => 'word']);
     $wordPermissionForUser = Permission::create(['name' => 'word.user', 'slug' => ['show' => false, 'update' => false, 'destroy' => false], 'inherit_id' => $wordPermission->getKey(), 'description' => 'word']);
     $wordTranslationPermission = Permission::create(['name' => 'word_translation', 'slug' => ['index' => true, 'store' => true, 'destroy' => true], 'description' => 'word_translation']);
     $wordTranslationPermissionForUser = Permission::create(['name' => 'word_translation.user', 'slug' => ['index' => true, 'store' => true, 'destroy' => false], 'inherit_id' => $wordTranslationPermission->getKey(), 'description' => 'word_translation.user']);
     $translationPermission = Permission::create(['name' => 'translation', 'slug' => ['index' => true, 'store' => true, 'show' => true, 'update' => true, 'destroy' => true], 'description' => 'translation']);
     $translationPermissionForUser = Permission::create(['name' => 'translation.user', 'slug' => ['show' => false, 'update' => false, 'destroy' => false], 'inherit_id' => $translationPermission->getKey(), 'description' => 'translation.user']);
     $positionPermission = Permission::create(['name' => 'position', 'slug' => ['index' => true], 'description' => 'position']);
     Role::where('slug', 'user')->first()->assignPermission([$userPermissionForUser, $exercisePermission, $exerciseTranslationPermission, $wordTranslationPermissionForUser, $wordPermissionForUser, $translationPermissionForUser]);
     Role::where('slug', 'admin')->first()->assignPermission([$userPermission, $wordPermission, $wordTranslationPermission, $translationPermission, $positionPermission]);
 }
Beispiel #8
0
 public function permissions($id)
 {
     $user = User::findOrFail($id);
     $tempUserPermissions = array();
     foreach ($user->getPermissions() as $key => $value) {
         $tempUserPermissions[$key] = $value;
     }
     $permissions = array();
     foreach (Permission::orderBy('name')->get()->toArray() as $pointer) {
         $permissions[$pointer['id']] = $pointer['name'];
         //because the ->getPermission() function does not return the ID, we'll need to rebuild it here
         if (in_array($pointer['slug'], $tempUserPermissions)) {
             $userPermissions[] = $pointer['id'];
         }
     }
     return view('pages.users.permissions', compact('user', 'permissions', 'userPermissions', 'id'));
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // Rules
     $roleAdmin = Role::create(['name' => 'Administrator', 'slug' => 'administrator', 'description' => 'Administrador geral do sistema']);
     $roleExecutive = Role::create(['name' => 'Executive', 'slug' => 'executive', 'description' => 'Usuario da categoria "Executive" do sistema']);
     $roleManager = Role::create(['name' => 'Manager', 'slug' => 'manager', 'description' => 'Usuario da categoria "Manager" do sistema']);
     $roleOperational = Role::create(['name' => 'Operational', 'slug' => 'operational', 'description' => 'Usuario da categoria "Operational" do sistema']);
     $roleStaff = Role::create(['name' => 'Staff', 'slug' => 'staff', 'description' => 'Usuario da categoria "Staff" do sistema']);
     //Vehicle
     //Permissions
     $permVehicleStaff = Permission::create(['name' => 'vehicle', 'slug' => ['create' => false, 'view' => false, 'update' => false, 'delete' => false], 'description' => 'Administra permissoes do vehicle para o nivel staff de usuario']);
     $permVehicleOperational = Permission::create(['name' => 'vehicle.operational', 'slug' => [], 'inherit_id' => $permVehicleStaff->getKey(), 'description' => 'Administra permissoes do vehicle para o nivel operational de usuario']);
     $permVehicleManager = Permission::create(['name' => 'vehicle.manager', 'slug' => [], 'inherit_id' => $permVehicleOperational->getKey(), 'description' => 'Administra permissoes do vehicle para o nivel manager de usuario']);
     $permVehicleExecutive = Permission::create(['name' => 'vehicle.executive', 'slug' => [], 'inherit_id' => $permVehicleManager->getKey(), 'description' => 'Administra permissoes do vehicle para o nivel executive de usuario']);
     $permVehicleAdmin = Permission::create(['name' => 'vehicle.admin', 'slug' => ['create' => true, 'view' => true, 'update' => true, 'delete' => true], 'inherit_id' => $permVehicleExecutive->getKey(), 'description' => 'Administra permissoes do vehicle para o nivel admin de usuario']);
     //Assign permissions to rules
     $roleStaff->assignPermission($permVehicleStaff);
     $roleOperational->assignPermission($permVehicleOperational);
     $roleManager->assignPermission($permVehicleManager);
     $roleExecutive->assignPermission($permVehicleExecutive);
     $roleAdmin->assignPermission($permVehicleAdmin);
     //Contact
     //Permissions
     $permContactStaff = Permission::create(['name' => 'contact', 'slug' => ['create' => false, 'view' => false, 'update' => false, 'delete' => false], 'description' => 'Administra permissoes do contact para o nivel staff de usuario']);
     $permContactOperational = Permission::create(['name' => 'contact.operational', 'slug' => [], 'inherit_id' => $permContactStaff->getKey(), 'description' => 'Administra permissoes do contact para o nivel operational de usuario']);
     $permContactManager = Permission::create(['name' => 'contact.manager', 'slug' => [], 'inherit_id' => $permContactOperational->getKey(), 'description' => 'Administra permissoes do contact para o nivel manager de usuario']);
     $permContactExecutive = Permission::create(['name' => 'contact.executive', 'slug' => [], 'inherit_id' => $permContactManager->getKey(), 'description' => 'Administra permissoes do contact para o nivel executive de usuario']);
     $permContactAdmin = Permission::create(['name' => 'contact.admin', 'slug' => ['create' => true, 'view' => true, 'update' => true, 'delete' => true], 'inherit_id' => $permContactExecutive->getKey(), 'description' => 'Administra permissoes do contact para o nivel admin de usuario']);
     //Assign permissions to rules
     $roleStaff->assignPermission($permContactStaff);
     $roleOperational->assignPermission($permContactOperational);
     $roleManager->assignPermission($permContactManager);
     $roleExecutive->assignPermission($permContactExecutive);
     $roleAdmin->assignPermission($permContactAdmin);
     //Trip
     //Permissions
     $permTripStaff = Permission::create(['name' => 'trip', 'slug' => ['create' => false, 'view' => false, 'update' => false, 'delete' => false], 'description' => 'Administra permissoes do trip para o nivel staff de usuario']);
     $permTripOperational = Permission::create(['name' => 'trip.operational', 'slug' => [], 'inherit_id' => $permTripStaff->getKey(), 'description' => 'Administra permissoes do trip para o nivel operational de usuario']);
     $permTripManager = Permission::create(['name' => 'trip.manager', 'slug' => [], 'inherit_id' => $permTripOperational->getKey(), 'description' => 'Administra permissoes do trip para o nivel manager de usuario']);
     $permTripExecutive = Permission::create(['name' => 'trip.executive', 'slug' => [], 'inherit_id' => $permTripManager->getKey(), 'description' => 'Administra permissoes do trip para o nivel executive de usuario']);
     $permTripAdmin = Permission::create(['name' => 'trip.admin', 'slug' => ['create' => true, 'view' => true, 'update' => true, 'delete' => true], 'inherit_id' => $permTripExecutive->getKey(), 'description' => 'Administra permissoes do trip para o nivel admin de usuario']);
     //Assign permissions to rules
     $roleStaff->assignPermission($permTripStaff);
     $roleOperational->assignPermission($permTripOperational);
     $roleManager->assignPermission($permTripManager);
     $roleExecutive->assignPermission($permTripExecutive);
     $roleAdmin->assignPermission($permTripAdmin);
     //Part
     //Permissions
     $permPartStaff = Permission::create(['name' => 'part', 'slug' => ['create' => false, 'view' => false, 'update' => false, 'delete' => false], 'description' => 'Administra permissoes do part para o nivel staff de usuario']);
     $permPartOperational = Permission::create(['name' => 'part.operational', 'slug' => [], 'inherit_id' => $permPartStaff->getKey(), 'description' => 'Administra permissoes do part para o nivel operational de usuario']);
     $permPartManager = Permission::create(['name' => 'part.manager', 'slug' => [], 'inherit_id' => $permPartOperational->getKey(), 'description' => 'Administra permissoes do part para o nivel manager de usuario']);
     $permPartExecutive = Permission::create(['name' => 'part.executive', 'slug' => [], 'inherit_id' => $permPartManager->getKey(), 'description' => 'Administra permissoes do part para o nivel executive de usuario']);
     $permPartAdmin = Permission::create(['name' => 'part.admin', 'slug' => ['create' => true, 'view' => true, 'update' => true, 'delete' => true], 'inherit_id' => $permPartExecutive->getKey(), 'description' => 'Administra permissoes do part para o nivel admin de usuario']);
     //Assign permissions to rules
     $roleStaff->assignPermission($permPartStaff);
     $roleOperational->assignPermission($permPartOperational);
     $roleManager->assignPermission($permPartManager);
     $roleExecutive->assignPermission($permPartExecutive);
     $roleAdmin->assignPermission($permPartAdmin);
     //Entry
     //Permissions
     $permEntryStaff = Permission::create(['name' => 'entry', 'slug' => ['create' => false, 'view' => false, 'update' => false, 'delete' => false], 'description' => 'Administra permissoes do entry para o nivel staff de usuario']);
     $permEntryOperational = Permission::create(['name' => 'entry.operational', 'slug' => [], 'inherit_id' => $permEntryStaff->getKey(), 'description' => 'Administra permissoes do entry para o nivel operational de usuario']);
     $permEntryManager = Permission::create(['name' => 'entry.manager', 'slug' => [], 'inherit_id' => $permEntryOperational->getKey(), 'description' => 'Administra permissoes do entry para o nivel manager de usuario']);
     $permEntryExecutive = Permission::create(['name' => 'entry.executive', 'slug' => [], 'inherit_id' => $permEntryManager->getKey(), 'description' => 'Administra permissoes do entry para o nivel executive de usuario']);
     $permEntryAdmin = Permission::create(['name' => 'entry.admin', 'slug' => ['create' => true, 'view' => true, 'update' => true, 'delete' => true], 'inherit_id' => $permEntryExecutive->getKey(), 'description' => 'Administra permissoes do entry para o nivel admin de usuario']);
     //Assign permissions to rules
     $roleStaff->assignPermission($permEntryStaff);
     $roleOperational->assignPermission($permEntryOperational);
     $roleManager->assignPermission($permEntryManager);
     $roleExecutive->assignPermission($permEntryExecutive);
     $roleAdmin->assignPermission($permEntryAdmin);
     //Model
     //Permissions
     $permModelStaff = Permission::create(['name' => 'model', 'slug' => ['create' => false, 'view' => false, 'update' => false, 'delete' => false], 'description' => 'Administra permissoes do model para o nivel staff de usuario']);
     $permModelOperational = Permission::create(['name' => 'model.operational', 'slug' => [], 'inherit_id' => $permModelStaff->getKey(), 'description' => 'Administra permissoes do model para o nivel operational de usuario']);
     $permModelManager = Permission::create(['name' => 'model.manager', 'slug' => [], 'inherit_id' => $permModelOperational->getKey(), 'description' => 'Administra permissoes do model para o nivel manager de usuario']);
     $permModelExecutive = Permission::create(['name' => 'model.executive', 'slug' => [], 'inherit_id' => $permModelManager->getKey(), 'description' => 'Administra permissoes do model para o nivel executive de usuario']);
     $permModelAdmin = Permission::create(['name' => 'model.admin', 'slug' => ['create' => true, 'view' => true, 'update' => true, 'delete' => true], 'inherit_id' => $permModelExecutive->getKey(), 'description' => 'Administra permissoes do model para o nivel admin de usuario']);
     //Assign permissions to rules
     $roleStaff->assignPermission($permModelStaff);
     $roleOperational->assignPermission($permModelOperational);
     $roleManager->assignPermission($permModelManager);
     $roleExecutive->assignPermission($permModelExecutive);
     $roleAdmin->assignPermission($permModelAdmin);
     //Attribute
     //Permissions
     $permAttributeStaff = Permission::create(['name' => 'attribute', 'slug' => ['create' => false, 'view' => false, 'update' => false, 'delete' => false], 'description' => 'Administra permissoes do attribute para o nivel staff de usuario']);
     $permAttributeOperational = Permission::create(['name' => 'attribute.operational', 'slug' => [], 'inherit_id' => $permAttributeStaff->getKey(), 'description' => 'Administra permissoes do attribute para o nivel operational de usuario']);
     $permAttributeManager = Permission::create(['name' => 'attribute.manager', 'slug' => [], 'inherit_id' => $permAttributeOperational->getKey(), 'description' => 'Administra permissoes do attribute para o nivel manager de usuario']);
     $permAttributeExecutive = Permission::create(['name' => 'attribute.executive', 'slug' => [], 'inherit_id' => $permAttributeManager->getKey(), 'description' => 'Administra permissoes do attribute para o nivel executive de usuario']);
     $permAttributeAdmin = Permission::create(['name' => 'attribute.admin', 'slug' => ['create' => true, 'view' => true, 'update' => true, 'delete' => true], 'inherit_id' => $permAttributeExecutive->getKey(), 'description' => 'Administra permissoes do attribute para o nivel admin de usuario']);
     //Assign permissions to rules
     $roleStaff->assignPermission($permAttributeStaff);
     $roleOperational->assignPermission($permAttributeOperational);
     $roleManager->assignPermission($permAttributeManager);
     $roleExecutive->assignPermission($permAttributeExecutive);
     $roleAdmin->assignPermission($permAttributeAdmin);
     //Role
     //Permissions
     $permRoleStaff = Permission::create(['name' => 'role', 'slug' => ['create' => false, 'view' => false, 'update' => false, 'delete' => false], 'description' => 'Administra permissoes do role para o nivel staff de usuario']);
     $permRoleOperational = Permission::create(['name' => 'role.operational', 'slug' => [], 'inherit_id' => $permRoleStaff->getKey(), 'description' => 'Administra permissoes do role para o nivel operational de usuario']);
     $permRoleManager = Permission::create(['name' => 'role.manager', 'slug' => [], 'inherit_id' => $permRoleOperational->getKey(), 'description' => 'Administra permissoes do role para o nivel manager de usuario']);
     $permRoleExecutive = Permission::create(['name' => 'role.executive', 'slug' => [], 'inherit_id' => $permRoleManager->getKey(), 'description' => 'Administra permissoes do role para o nivel executive de usuario']);
     $permRoleAdmin = Permission::create(['name' => 'role.admin', 'slug' => ['create' => true, 'view' => true, 'update' => true, 'delete' => true], 'inherit_id' => $permRoleExecutive->getKey(), 'description' => 'Administra permissoes do role para o nivel admin de usuario']);
     //Assign permissions to rules
     $roleStaff->assignPermission($permRoleStaff);
     $roleOperational->assignPermission($permRoleOperational);
     $roleManager->assignPermission($permRoleManager);
     $roleExecutive->assignPermission($permRoleExecutive);
     $roleAdmin->assignPermission($permRoleAdmin);
     //Type
     //Permissions
     $permTypeStaff = Permission::create(['name' => 'type', 'slug' => ['create' => false, 'view' => false, 'update' => false, 'delete' => false], 'description' => 'Administra permissoes do type para o nivel staff de usuario']);
     $permTypeOperational = Permission::create(['name' => 'type.operational', 'slug' => [], 'inherit_id' => $permTypeStaff->getKey(), 'description' => 'Administra permissoes do type para o nivel operational de usuario']);
     $permTypeManager = Permission::create(['name' => 'type.manager', 'slug' => [], 'inherit_id' => $permTypeOperational->getKey(), 'description' => 'Administra permissoes do type para o nivel manager de usuario']);
     $permTypeExecutive = Permission::create(['name' => 'type.executive', 'slug' => [], 'inherit_id' => $permTypeManager->getKey(), 'description' => 'Administra permissoes do type para o nivel executive de usuario']);
     $permTypeAdmin = Permission::create(['name' => 'type.admin', 'slug' => ['create' => true, 'view' => true, 'update' => true, 'delete' => true], 'inherit_id' => $permTypeExecutive->getKey(), 'description' => 'Administra permissoes do type para o nivel admin de usuario']);
     //Assign permissions to rules
     $roleStaff->assignPermission($permTypeStaff);
     $roleOperational->assignPermission($permTypeOperational);
     $roleManager->assignPermission($permTypeManager);
     $roleExecutive->assignPermission($permTypeExecutive);
     $roleAdmin->assignPermission($permTypeAdmin);
     //Company
     //Permissions
     $permCompanyStaff = Permission::create(['name' => 'company', 'slug' => ['create' => false, 'view' => false, 'update' => false, 'delete' => false], 'description' => 'Administra permissoes do company para o nivel staff de usuario']);
     $permCompanyOperational = Permission::create(['name' => 'company.operational', 'slug' => [], 'inherit_id' => $permCompanyStaff->getKey(), 'description' => 'Administra permissoes do company para o nivel operational de usuario']);
     $permCompanyManager = Permission::create(['name' => 'company.manager', 'slug' => [], 'inherit_id' => $permCompanyOperational->getKey(), 'description' => 'Administra permissoes do company para o nivel manager de usuario']);
     $permCompanyExecutive = Permission::create(['name' => 'company.executive', 'slug' => [], 'inherit_id' => $permCompanyManager->getKey(), 'description' => 'Administra permissoes do company para o nivel executive de usuario']);
     $permCompanyAdmin = Permission::create(['name' => 'company.admin', 'slug' => ['create' => true, 'view' => true, 'update' => true, 'delete' => false], 'inherit_id' => $permCompanyExecutive->getKey(), 'description' => 'Administra permissoes do company para o nivel admin de usuario']);
     //Assign permissions to rules
     $roleStaff->assignPermission($permCompanyStaff);
     $roleOperational->assignPermission($permCompanyOperational);
     $roleManager->assignPermission($permCompanyManager);
     $roleExecutive->assignPermission($permCompanyExecutive);
     $roleAdmin->assignPermission($permCompanyAdmin);
     //User
     //Permissions
     $permUserStaff = Permission::create(['name' => 'user', 'slug' => ['create' => false, 'view' => false, 'update' => false, 'delete' => false], 'description' => 'Administra permissoes do user para o nivel staff de usuario']);
     $permUserOperational = Permission::create(['name' => 'user.operational', 'slug' => [], 'inherit_id' => $permUserStaff->getKey(), 'description' => 'Administra permissoes do user para o nivel operational de usuario']);
     $permUserManager = Permission::create(['name' => 'user.manager', 'slug' => [], 'inherit_id' => $permUserOperational->getKey(), 'description' => 'Administra permissoes do user para o nivel manager de usuario']);
     $permUserExecutive = Permission::create(['name' => 'user.executive', 'slug' => [], 'inherit_id' => $permUserManager->getKey(), 'description' => 'Administra permissoes do user para o nivel executive de usuario']);
     $permUserAdmin = Permission::create(['name' => 'user.admin', 'slug' => ['create' => true, 'view' => true, 'update' => true, 'delete' => true], 'inherit_id' => $permUserExecutive->getKey(), 'description' => 'Administra permissoes do user para o nivel admin de usuario']);
     //Assign permissions to rules
     $roleStaff->assignPermission($permUserStaff);
     $roleOperational->assignPermission($permUserOperational);
     $roleManager->assignPermission($permUserManager);
     $roleExecutive->assignPermission($permUserExecutive);
     $roleAdmin->assignPermission($permUserAdmin);
     //Assign role to user
     $user = User::first();
     if ($user) {
         $user->assignRole($roleAdmin);
     }
 }
Beispiel #10
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function postUserPermissions(Request $request, $id)
 {
     $user = User::find($id);
     $permissions = Permission::all();
     foreach ($permissions as $permission) {
         if (Input::get($permission->name)) {
             $user->addPermission($permission->name);
         } else {
             $user->removePermission($permission->name);
         }
     }
     $user->save();
     return Redirect::to('/admin/user');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     //
     Permission::findOrFail($id)->delete();
     flash()->success('Success', 'The permission has been deleted successfully');
     return redirect('/admin/permissions');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     Permission::destroy($id);
     return Redirect::to('/admin/permission');
 }
 public function destroy($id)
 {
     $permission = Permission::find($id);
     $permission->delete();
     return response()->json(['id' => $id]);
 }
 public function permissions()
 {
     return view('admin.permissions', ['permissions' => Permission::get()]);
 }
Beispiel #15
0
 public function permissions($id)
 {
     $permissions = array(0 => 'None');
     foreach (Permission::select('id', 'name')->orderBy('name', 'asc')->get()->toArray() as $pointer) {
         $permissions[$pointer['id']] = $pointer['name'];
     }
     $rolePermissions = array();
     foreach (Role::findOrFail($id)->permissions->toArray() as $pointer) {
         $rolePermissions[] = $pointer['id'];
     }
     return view('pages.roles.permissions', compact('id', 'permissions', 'rolePermissions'));
 }