コード例 #1
0
ファイル: Registrar.php プロジェクト: jumaya/redbpim
 public function createRole(array $data)
 {
     $getid = \DB::table('users')->where('email', '=', $data['correo_electronico'])->where('user_login', '=', $data['nombre_usuario'])->where('num_identificacion', '=', $data['numero_identificacion'])->first();
     return RolesUsers::create(['user_id' => $getid->id, 'role_id' => $data['rol_usuario']]);
 }
コード例 #2
0
 public function run()
 {
     RolesUsers::create(['role_id' => '5', 'user_id' => '1']);
     RolesUsers::create(['role_id' => '3', 'user_id' => '1']);
 }
コード例 #3
0
ファイル: AdminController.php プロジェクト: jumaya/redbpim
 public function storeRoles($id)
 {
     $level1 = \Input::get('user' . $id . 'level1');
     $level2 = \Input::get('user' . $id . 'level2');
     $level3 = \Input::get('user' . $id . 'level3');
     $level4 = \Input::get('user' . $id . 'level4');
     $level5 = \Input::get('user' . $id . 'level5');
     if ($level5 == false and $level4 == false and $level3 == false and $level2 == false and $level1 == false) {
         return $this->GestionRolesSearch()->withErrors(['alertBadRol' => 'Debe asginar al menos un rol..!']);
     }
     if ($level5 == true or $level4 == true and $level1 == false and $level2 == false and $level3 == false) {
         return $this->GestionRolesSearch()->withErrors(['alertBadRol' => 'El usuario no puede tener solo el rol de administrador. Verifique esto..!']);
     }
     if ($level5 == true and $level4 == true) {
         return $this->GestionRolesSearch()->withErrors(['alertBadRol' => 'El usuario no puede tener dos roles de administrador..!']);
     }
     if ($level5 == true and $level2 == true) {
         return $this->GestionRolesSearch()->withErrors(['alertBadRol' => 'El usuario no puede tener los roles de Administrador Departamental y Secretaria de Planeación Municipal. Verifique esto..!']);
     }
     if ($level4 == true and $level3 == true) {
         return $this->GestionRolesSearch()->withErrors(['alertBadRol' => 'El usuario no puede tener los roles de Administrador Municipal y Secretaria de Planeación Departamental. Verifique esto..!']);
     }
     if ($level3 == true and $level2 == true) {
         return $this->GestionRolesSearch()->withErrors(['alertBadRol' => 'El usuario no puede tener los roles de Secretaría de Planeación Departamental y Municipal. Verifique esto..!']);
     }
     if ($level1 == true and User::find($id)->hasRole('secsectorial') == false) {
         $saverol = new RolesUsers();
         $saverol->user_id = $id;
         $saverol->role_id = 1;
         $saverol->save();
     }
     if ($level2 == true and User::find($id)->hasRole('secmunicipal') == false) {
         $saverol = new RolesUsers();
         $saverol->user_id = $id;
         $saverol->role_id = 2;
         $saverol->save();
     }
     if ($level3 == true and User::find($id)->hasRole('secdepartamental') == false) {
         $saverol = new RolesUsers();
         $saverol->user_id = $id;
         $saverol->role_id = 3;
         $saverol->save();
     }
     if ($level4 == true and User::find($id)->hasRole('adminmunicipal') == false) {
         $saverol = new RolesUsers();
         $saverol->user_id = $id;
         $saverol->role_id = 4;
         $saverol->save();
     }
     if ($level5 == true and User::find($id)->hasRole('admin') == false) {
         $saverol = new RolesUsers();
         $saverol->user_id = $id;
         $saverol->role_id = 5;
         $saverol->save();
     }
     //ELIMINAR ROLES
     if ($level1 == false) {
         $deleteRol = \DB::table('role_user')->where('user_id', '=', $id)->where('role_id', '=', 1);
         $deleteRol->delete();
     }
     if ($level2 == false) {
         $deleteRol = \DB::table('role_user')->where('user_id', '=', $id)->where('role_id', '=', 2);
         $deleteRol->delete();
     }
     if ($level3 == false) {
         $deleteRol = \DB::table('role_user')->where('user_id', '=', $id)->where('role_id', '=', 3);
         $deleteRol->delete();
     }
     if ($level4 == false) {
         $deleteRol = \DB::table('role_user')->where('user_id', '=', $id)->where('role_id', '=', 4);
         $deleteRol->delete();
     }
     if ($level5 == false) {
         $deleteRol = \DB::table('role_user')->where('user_id', '=', $id)->where('role_id', '=', 5);
         $deleteRol->delete();
     }
     return $this->GestionRolesSearch()->withErrors(['alerSuccesRol' => 'Los cambios fueron guardados exitosamente..!']);
 }