Beispiel #1
0
 public function run()
 {
     DB::table('roles')->delete();
     Roles::create(['rl_name' => 'SAdmin', 'rl_description' => 'Overall Administrator Role', 'created_by' => 1]);
     Roles::create(['rl_name' => 'Admin', 'rl_description' => 'General Administrator Role', 'created_by' => 1]);
     Roles::create(['rl_name' => 'Usuario', 'rl_description' => 'Default Role', 'created_by' => 1]);
 }
 public function run()
 {
     $roles = [['name' => 'Desarrollo Profesional', 'abbr' => 'depro'], ['name' => 'Jefe de Departamento', 'abbr' => 'jdepartamento'], ['name' => 'Usuario', 'abbr' => 'usr'], ['name' => 'Docente', 'abbr' => 'docente']];
     foreach ($roles as $rol) {
         Rol::create($rol);
     }
 }
 public function rolesAjax(Request $request)
 {
     if ($request->ajax()) {
         return Roles::all()->toJson();
     } else {
         return redirect('/');
     }
 }
 private function retrieveRoleIdByName($roleName)
 {
     $role = Roles::where("name", $roleName)->first();
     if ($role === null) {
         throw new BadRequestHttpException("Provided role does not exists.");
     }
     return $role->id;
 }
Beispiel #5
0
 public function return_view()
 {
     if (\Auth::check()) {
         return \View::make('add_delete')->with('roles_present', Roles::all())->with('operations_present', Operations::all())->with('resources_present', Resources::all());
     } else {
         \Session::flash('status', 'Please login!');
         return redirect('login');
     }
 }
Beispiel #6
0
 public function return_view()
 {
     if (\Auth::check()) {
         return \View::make('roles')->with('roles', User::all())->with('roles_data', Roles::all());
     } else {
         \Session::flash('status', 'Please login!');
         return redirect('login');
     }
 }
 /**
  * @param $id
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function modificar($id)
 {
     $detalle_roles = [];
     $detalle = DetalleUsuario::where('id', $id)->get(['id_rol']);
     foreach ($detalle as $rol) {
         array_push($detalle_roles, intval($rol->id_rol));
     }
     $data = ['roles' => Roles::get(), 'detalle' => $detalle_roles, 'departamentos' => Departamentos::get(), 'user' => Users::find($id)];
     return view('profiles.depro.users.modify', $data);
 }
 public function handle($request, Closure $next)
 {
     if ($this->auth->check()) {
         $user = Auth::user();
         $role = Roles::where('id', $user->role_id)->firstOrFail();
         if ($role->name === "Administrator") {
             return redirect()->intended('/administration');
         }
         return redirect()->intended('/');
     }
     return $next($request);
 }
 public function handle($request, Closure $next)
 {
     $user = Auth::user();
     if ($user === null) {
         throw new HttpException(500, "Failed to retrieve authenticated user.");
     }
     $role = Roles::where('id', $user->role_id)->firstOrFail();
     if ($role->name !== "Administrator") {
         throw new AccessDeniedHttpException("Permission are required to access this resources.");
     }
     return $next($request);
 }
Beispiel #10
0
 public function edit($id)
 {
     $user = User::findOrFail($id);
     $roles = Roles::lists('description', 'id');
     return view('admin.users.edit', compact('user', 'roles'));
 }
Beispiel #11
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $this->authorize(new Permissions());
     $usr_role = \App\User::where('usr_role', $id)->update(['usr_role' => 3]);
     //assign the default role to a user when the current role is deleted.
     $roles = Roles::find($id);
     $roles->delete();
     Session::flash('message', 'Rol Eliminado Exitosamente.');
     return Redirect::to('roles');
 }
 /**
  * Show the application dashboard.
  *
  * @return Response
  */
 public function index()
 {
     $roles = \App\Roles::all();
     $user = \App\User::all();
     return view('home')->with(['roles' => $roles, 'user' => $user]);
 }
 function manage_role()
 {
     $users = User::all();
     $roles = Roles::all();
     return view('managerole', ['users' => $users, 'roles' => $roles]);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(RolesRequest $roles, $id)
 {
     //this is method to saving
     $roles = Roles::find($id);
     $roles->name = Input::get('name');
     $roles->access = json_encode(Input::get('access'));
     $roles->save();
     Session::flash('message', 'You have successfully added Roles');
     return Redirect::to('roles');
 }
 public function edit()
 {
     $user = $this->user;
     $roles = Roles::lists('name', 'id')->toArray();
     return view('edituser', compact('user', 'roles'));
 }
Beispiel #16
0
 public function send_data(Request $request)
 {
     #----------- get the role name
     $arr = array();
     $arr['role_name'] = $request->selected;
     #----------- fetch the id of that role
     $id = Roles::where('type', $arr['role_name'])->first();
     #---------- fetch the operations and id of the operations
     $operations = Operations::all()->sort();
     #----------  fetch resources and id of resources
     $resources = Resources::all();
     #---------- for counting the number of rows that match the condition
     $count = Privileges::where('rolesid', $id->id)->count();
     #---------- fetching data upto count
     $privileges = Privileges::where('rolesid', $id->id)->take($count)->get();
     $str = "<div class = 'table'>";
     #----------  now loop that consists of other loops
     #----------  it loops around the number of resources
     foreach ($resources as $resource_info) {
         $i = 0;
         $str .= "<div class='row'>";
         $str .= "<br>" . "<div class='col-lg-4 '>";
         $str .= $resource_info->name . ":---->";
         $str .= "</div>";
         $oper_info = array();
         if (!empty($privileges)) {
             #--------to decide how many privileges will be there for a particular resource
             foreach ($privileges as $priv_info) {
                 if ($priv_info->resourceid == $resource_info->id) {
                     $oper_info[$i] = $priv_info->operationid;
                     $i++;
                 }
             }
             sort($oper_info);
             $number_of_actions = 0;
             $count_array = count($oper_info);
             $a = array();
             #------------it is necessary to check for non empty values
             if (!empty($oper_info)) {
                 foreach ($operations as $key => $value) {
                     $str .= "<div class='col-lg-2 '>";
                     if ($number_of_actions < $count_array && $value->id == $oper_info[$number_of_actions]) {
                         $str .= $value->actions . " : " . ' <input type="checkbox" ' . 'onchange="my_dynamic_function(this.checked, ' . $id->id . ',' . $resource_info->id . ', ' . $value->id . ')" ' . ' name="option" value="" checked = "checked" >-----';
                         if ($number_of_actions < $count_array) {
                             $number_of_actions++;
                         }
                     } else {
                         $str .= $value->actions . " : " . ' <input type="checkbox" ' . 'onchange="my_dynamic_function(this.checked, ' . $id->id . ',' . $resource_info->id . ', ' . $value->id . ')" ' . ' name="option" value="" >-----';
                     }
                     $str .= "</div>";
                 }
             } else {
                 foreach ($operations as $key => $value) {
                     $str .= "<div class='col-lg-2 '>";
                     $str .= $value->actions . " : " . ' <input type="checkbox" ' . 'onchange="my_dynamic_function(this.checked, ' . $id->id . ',' . $resource_info->id . ', ' . $value->id . ')" ' . ' name="option" value="" >-----';
                     $str .= "</div>";
                 }
             }
         }
         $str .= "<br>";
         $str .= "</div>";
     }
     $str .= '</div>';
     return response()->json($str);
 }
Beispiel #17
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $this->authorize(new Permissions());
     $Item = User::find($id);
     $this->authorize($Item);
     $usr_role = \Auth::user()->usr_role;
     $rlList = Roles::where('rl_enabled', '1')->where('id', '>=', $usr_role)->select('id', 'rl_name')->get();
     return view('admin.user.edit')->with('Item', $Item)->with('rlList', $rlList);
 }
Beispiel #18
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     Roles::destroy($id);
     return redirect()->route('roles.index');
 }
 public function delete(StatusRequest $requests)
 {
     $roles = Roles::findOrFail($requests->input('id'));
     $roles->delete();
 }