Ejemplo n.º 1
0
 public function run()
 {
     DB::table('roles')->delete();
     $role = new Role();
     $role->name = 'edit_site';
     $role->description = 'Editar Sitio';
     $role->save();
     $role = new Role();
     $role->name = 'crud_user';
     $role->description = 'Manejo Usuarios';
     $role->save();
     $role = new Role();
     $role->name = 'crud_organization';
     $role->description = 'Crear Muestras';
     $role->save();
     $role = new Role();
     $userRole = new UserRole();
     $userRole->user_id = 1;
     $userRole->role_id = 1;
     $userRole->save();
     $userRole = new UserRole();
     $userRole->user_id = 1;
     $userRole->role_id = 2;
     $userRole->save();
     $userRole = new UserRole();
     $userRole->user_id = 2;
     $userRole->role_id = 3;
     $userRole->save();
     $userRole = new UserRole();
     $userRole->user_id = 2;
     $userRole->role_id = 2;
     $userRole->save();
 }
Ejemplo n.º 2
0
 public function makeSiteUser($title)
 {
     $assigned_roles = array();
     $roles = array_fetch(Role::all()->toArray(), 'name');
     switch ($title) {
         case 'super_admin':
             $assigned_roles[] = $this->getIdInArray($roles, 'edit_site');
             $assigned_roles[] = $this->getIdInArray($roles, 'crud_user');
         case 'admin':
             $assigned_roles[] = $this->getIdInArray($roles, 'edit_site');
             $assigned_roles[] = $this->getIdInArray($roles, 'crud_user');
             $assigned_roles[] = $this->getIdInArray($roles, 'create_region');
             $assigned_roles[] = $this->getIdInArray($roles, 'create_competition');
         case 'community_editor':
             $assigned_roles[] = $this->getIdInArray($roles, 'edit_region');
             $assigned_roles[] = $this->getIdInArray($roles, 'crud_region_user');
             $assigned_roles[] = $this->getIdInArray($roles, 'create_competition');
             break;
         default:
             throw new \Exception("The user status entered does not exist");
     }
     $this->roles()->attach($assigned_roles);
 }
Ejemplo n.º 3
0
 public function destroy($id)
 {
     Role::destroy($id);
 }