public function __construct(Role_user $role_user, RoleHelper $roleHelper)
 {
     $this->middleware('auth');
     if (Auth::check()) {
         $this->roleHelper = $roleHelper;
         $this->bool_has_role = $role_user->hasRole('test preparer');
     }
     // end if Auth::check()
 }
 public function __construct(Role_user $role_user, RoleHelper $roleHelper)
 {
     $this->middleware('auth');
     if (Auth::check()) {
         $this->bool_has_role = $role_user->hasRole('test provider organization');
         if ($this->bool_has_role) {
             $this->obj_logged_in_user = Auth::user();
             $this->arr_logged_in_user = $roleHelper->prepare_logged_in_user_info($this->obj_logged_in_user);
         }
     }
 }
 public function get_role_info_admin(Request $request, Role $role, Role_user $role_user)
 {
     if (!$this->bool_has_role) {
         return $this->roleHelper->call_redirect();
     } else {
         $validation_rules = ['user_id' => 'required|integer|min:1'];
         $this->validate($request, $validation_rules);
         $arr_all_roles = $role->all();
         $arr_roles_possessed = $role_user->get_roles_possessed($request->user_id);
         $arr_roles_possessed = $role_user->process_roles_possessed_output($arr_roles_possessed);
         $arr_roles_available = $role_user->get_roles_available($request->user_id);
         $data = array('arr_roles_possessed' => $arr_roles_possessed, 'arr_roles_available' => $arr_roles_available);
         return response()->json($data);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $obj_role = $this->role->where('name', 'admin')->first();
     $obj_user = $this->user->where('email', '*****@*****.**')->first();
     DB::table('role_user')->delete();
     Role_user::create(array('role_id' => $obj_role->id, 'user_id' => $obj_user->id));
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create()
 {
     $training = Training::lists('training_name', 'id');
     $trainees = User::lists('id', 'name');
     //dd($trainees);
     $newTrainees = array();
     $test = "";
     foreach ($trainees as $traineesName => $traineeId) {
         $listOfTraineesInRoleTable = Role_user::whereuser_id($traineeId)->firstOrFail();
         if ($listOfTraineesInRoleTable->role_id == 3) {
             $traineeHas = UserTraining::whereuser_id($traineeId)->first();
             if ($traineeHas == true) {
                 $test++;
             } else {
                 array_push($newTrainees, $traineeId);
             }
         } else {
             continue;
         }
     }
     //print_r($newTrainees);
     return view('user_traininginfo/create', compact('training', 'trainees', 'newTrainees', 'listOfTraineeInRoleTable'));
 }
Esempio n. 6
0
 public function update_user($id, Request $request)
 {
     $user = User::findOrFail($id);
     $user->name = $request->get('name');
     $user->email = $request->get('email');
     $user->save();
     $role_user = Role_user::whereUser_id($user->id)->first();
     $role_user->role_id = $request->get('role_id');
     $role_user->save();
     return redirect('user/all')->with('status', 'User info update successfully');
 }
 public function post_delete_role(Request $request, User $user, Role $role, Role_user $role_user, Admin $admin)
 {
     $validation_rules = $admin->getValidationRulesAddRole();
     $validation_messages = $admin->getValidationMessagesEditUser();
     $this->validate($request, $validation_rules, $validation_messages);
     $arr_request = $admin->getRequestArrayAddRole($request);
     $role_user->delete_role($arr_request['user_id'], $arr_request['role_id']);
     //prepare text for output
     $user = $user->find($arr_request['user_id']);
     $arr_request['first_name'] = $user->first_name;
     $arr_request['last_name'] = $user->last_name;
     $role = $role->find($arr_request['role_id']);
     $arr_request['role'] = $role->name;
     $data = $admin->getDataArray($arr_request, 0, $this->arr_logged_in_user);
     return view('admin/delete_role_results_admin')->with('data', $data);
 }