Example #1
0
 public function updateLevel(Request $request)
 {
     $user = User::with(['level', 'courses' => function ($query) {
         $query->where('level', '1')->where('validated', 1);
     }])->where('id', $request->id)->first();
     $oldLevel = ucfirst($user->level->name);
     if (Auth::check()) {
         if (Auth::user()->id != $user->id) {
             if (Auth::user()->level_id == 5 || Auth::user()->level_id == 4 && $user->level_id < 4) {
                 if ($request->level < 3 && $user->courses->count() > 0) {
                     Flash::error('Impossible de rétrograder cet utilisateur à ce level car il est professeur de ' . $user->courses->count() . ' cours.');
                     return Redirect::back();
                 }
                 $newLevel = ucfirst(Level::find($request->level)->name);
                 $modif = $user->level_id > $request->level ? 'downgraded' : 'upgraded';
                 $user->level_id = $request->level;
                 $user->save();
                 Flash::success('Le changement a été effectué avec succès.');
                 makeModification('users', printUserLinkV2($user) . ' as been ' . $modif . ' from ' . $oldLevel . ' to ' . $newLevel . '.');
                 return Redirect::back();
             }
         }
     }
     Flash::error('Vous n\'avez pas les droits nécéssaires pour cela.');
     return Redirect::back();
 }
Example #2
0
 public function index(User $user, $type = null)
 {
     if (!Entrust::can('manage_user')) {
         return redirect('/dashboard')->withErrors(config('constants.NA'));
     }
     $query = $user->with('roles');
     if ($type != null) {
         $query->whereHas('roles', function ($qry) use($type) {
             $qry->where('name', '=', $type);
         });
     }
     $users = $query->get();
     $col_data = array();
     $col_heads = array(trans('messages.Option'), trans('messages.Name'), trans('messages.Username'), trans('messages.Email'), trans('messages.Department'), trans('messages.Role'));
     $col_heads = Helper::putCustomHeads($this->form, $col_heads);
     $col_ids = Helper::getCustomColId($this->form);
     $values = Helper::fetchCustomValues($this->form);
     $token = csrf_token();
     foreach ($users as $user) {
         foreach ($user->roles as $role) {
             $role_name = $role->display_name;
         }
         $cols = array('<div class="btn-group btn-group-xs">' . '<a href="/user/' . $user->id . '" class="btn btn-default btn-xs" data-toggle="tooltip" title="View"> <i class="fa fa-share"></i></a> ' . '<a href="/user/welcomeEmail/' . $user->id . '/' . $token . '" class="btn btn-default btn-xs" data-toggle="tooltip" title="Send Welcome Email"> <i class="fa fa-envelope"></i></a>' . '<a href="/user/' . $user->id . '/edit" class="btn btn-default btn-xs" data-toggle="tooltip" title="Edit"> <i class="fa fa-edit"></i></a> ' . delete_form(['user.destroy', $user->id]) . '</div>', $user->name, $user->username, $user->email, $user->Profile->department_id != null ? $user->Profile->Department->department_name : '', $role_name);
         $id = $user->id;
         foreach ($col_ids as $col_id) {
             array_push($cols, isset($values[$id][$col_id]) ? $values[$id][$col_id] : '');
         }
         $col_data[] = $cols;
     }
     Helper::writeResult($col_data);
     return view('user.index', compact('col_heads'));
 }
Example #3
0
 public function showGroup()
 {
     $customer_id = Auth::user()->customer->id;
     $group = User::with('unpaidOrders')->where('customer_id', $customer_id)->get();
     $spendings = Customer::find($customer_id)->unpaidOrders->sum('total_price');
     return view('account.group', compact('group', 'spendings'));
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $this->authorize('users-edit');
     $user = User::with('roles')->findOrFail($id);
     $roles = Role::orderBy('display_name')->get();
     return view('users.edit', compact('roles', 'user'));
 }
Example #5
0
 public function show($id)
 {
     //show single
     $record = User::with($this->related)->findOrFail($id);
     $record['fullname'] = $record->fullname;
     return $record;
 }
Example #6
0
 /**
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function show(Request $request)
 {
     $questions = ProfileQuestion::join('profiles_answers', 'profiles_questions.id', '=', 'profiles_answers.profile_question_id')->where('profiles_answers.user_id', $request->id)->get();
     $user = User::with('achievements')->where('users.id', $request->id)->first();
     //$users = User::where('category_id', 2)->where('id', '<>', Auth::user()->id)->get();
     return view('members/show', ['user' => $user, 'questions' => $questions]);
 }
Example #7
0
 public function getAll()
 {
     // return User::with('roles')->orderBy('first_name')->get();
     return User::with('roles')->whereHas('roles', function ($q) {
         $q->where('name', '!=', 'Medico')->where('name', '!=', 'Farmacista');
     })->orderBy('first_name')->get();
 }
Example #8
0
 public function getUserByIdWithRole($id)
 {
     $users = User::with('userRole')->with(['projects' => function ($q) {
         return $q->selectRaw('group_concat(projects.id) as project_ids');
     }])->find($id);
     return $users;
 }
Example #9
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     abort_unauthorized($id);
     $user = User::with('sessions')->findOrFail($id);
     $user->currentSessionHash = \App\ValidSession::generateFingerprint(request())['hash'];
     return $user;
 }
Example #10
0
 public function users()
 {
     $users = User::with('organization', 'roles')->get(['id', 'name', 'email', 'organization_id']);
     $orgs = Organization::all();
     $roles = Role::all();
     return Datatables::of($users)->addColumn('organization', function ($user) use($orgs) {
         $orgSelect = '<select name="organization" class="form-control organization" data-userid="' . $user->id . '">';
         foreach ($orgs as $org) {
             $select = "";
             if ($org->id == $user->organization_id) {
                 $select = 'selected';
             }
             $orgSelect .= '<option value="' . $org->id . '" ' . $select . '>' . $org->name . '</option>';
         }
         $orgSelect .= '</select>';
         //return '<a href="#edit-'.$user->id.'" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> '.$user->organization->name.'</a>';
         return $orgSelect;
     })->addColumn('role', function ($user) use($roles) {
         $roleSelect = '<select name="organization" class="form-control role" data-userid="' . $user->id . '">';
         foreach ($roles as $role) {
             $select = "";
             if ($user->hasRole($role->name)) {
                 $select = 'selected';
             }
             $roleSelect .= '<option value="' . $role->id . '" ' . $select . '>' . $role->display_name . '</option>';
         }
         $roleSelect .= '</select>';
         //return '<a href="#edit-'.$user->id.'" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> '.$user->roles[0]->display_name.'</a>';
         return $roleSelect;
     })->removeColumn('id')->removeColumn('organization_id')->make(true);
 }
Example #11
0
 public function getAll()
 {
     // Get All Users
     $users = User::with('role')->get();
     // Passing data to response service
     return $this->responseService->returnMessage($users, 'No Users were Found.');
 }
Example #12
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $all_user_details = User::with('uploadDetail')->get();
     $users = array();
     foreach ($all_user_details as $key => $value) {
         $users[$key]['id'] = $value->id;
         $users[$key]['name'] = $value->name;
         $users[$key]['email'] = $value->email;
         $users[$key]['username'] = $value->username;
         $users[$key]['age'] = $value->age;
         $users[$key]['allow_payment'] = $value->name;
         $users[$key]['created_at'] = $value->created_at;
         foreach ($all_user_details[$key]->uploadDetail as $key1 => $value1) {
             $users[$key]['upload_detail'][$key1]['id'] = $value1->id;
             $users[$key]['upload_detail'][$key1]['user_id'] = $value1->user_id;
             $users[$key]['upload_detail'][$key1]['file_destination'] = $value1->file_destination;
             $users[$key]['upload_detail'][$key1]['file_name'] = $value1->file_name;
             $users[$key]['upload_detail'][$key1]['status'] = $value1->status;
             $users[$key]['upload_detail'][$key1]['payment_status'] = $value1->payment_status;
             $users[$key]['upload_detail'][$key1]['is_selected'] = $value1->is_selected;
             $users[$key]['upload_detail'][$key1]['season_name'] = $value1->season_name;
             $users[$key]['upload_detail'][$key1]['created_at'] = $value1->created_at->toDateTimeString();
             $users[$key]['upload_detail'][$key1]['updated_at'] = $value1->updated_at->toDateTimeString();
         }
     }
     // return $users;
     $data = array("users" => $users);
     // return $all_user_details;
     return view('users', $data);
 }
Example #13
0
 public function getEmployee()
 {
     if (!empty($this->employee)) {
         return $this->employee;
     }
     return $this->employee = User::with('Employee')->whereId($this->user->id)->first();
 }
Example #14
0
 /**
  * Display the instructor profile.
  *
  * @return Response
  */
 public function getProfile($id = Null)
 {
     if (isset($id)) {
         //The instructor with the given user_id
         $instructor = User::with('instructor')->has('instructor')->where('active', 1)->find($id);
         if (count($instructor) == 1) {
             //Instructor_id of the instructor
             $instructor_id = $instructor->instructor->instructor_id;
             //All reviews of the instructor
             $reviews = Instructor::find($instructor_id)->reviews()->orderBy('created_at', 'desc')->paginate(2);
             $reviews->setPath('/drive/instructor/profile/83/url');
             //Counting the number of reviews wrote by the current learner for the instructor
             // $no_of_review = Review::where('learner_id', Auth::user()->learner->learner_id)->where('Instructor_id', $instructor_id)->count();
             //Counting total number of reviews of the instructor
             $total_reviews = Instructor::find($instructor_id)->reviews()->count();
             //Calculating the average rating
             $avg_rating = Instructor::find($instructor_id)->reviews()->avg('rating');
             //
             $images = Image::where('instructor_id', $instructor_id)->get();
             //Returning the view with $instructors
             return view('instructor_profile', ['instructor' => $instructor, 'reviews' => $reviews, 'total_reviews' => $total_reviews, 'avg_rating' => $avg_rating, 'images' => $images]);
         } else {
             //If no result, redirect the user to the instructor_list
             //Flashed data contains message and alert-danger class
             return redirect()->action('InstructorController@getIndex')->with('message', 'No instructor profile found!')->with('alert-class', 'alert-danger');
         }
         //End of if statement
     } else {
         //If no id provided, redirect the user to the instructor_list
         return redirect()->action('InstructorController@getIndex');
     }
     //End of if statement
 }
Example #15
0
 public function index(Request $request)
 {
     $s = $request->s ? $request->s : '';
     $users = User::with('roles')->whereUser($s)->latest()->paginate(10);
     $roles = Role::orderBy('id', 'ASC')->get(['id', 'name']);
     return view('admin.users.index', compact('users', 'roles', 's'));
 }
 /**
  * @return Collection
  */
 public function getUserPost() : Collection
 {
     //        return User::where('id', '>', 2)
     //            ->where('id', '<', 6)
     //            ->get();
     return User::with('post')->where('id', '>', 2)->where('id', '<', 6)->get();
 }
Example #17
0
 public function getAll()
 {
     // return User::with('roles')->orderBy('first_name')->get();
     return User::with('roles', 'profile.provincia_albo_rel', 'profile.specializzazione_rel')->whereHas('roles', function ($q) {
         $q->whereIn('name', ['Medico', 'Farmacista']);
     })->orderBy('first_name')->get();
 }
Example #18
0
 public function profile()
 {
     $user_id = app('auth')->user()->getKey();
     $user = User::with('wishlists', 'wishlists.givingCircle', 'wishlists.items')->where('id', '=', $user_id)->get()->first();
     js(['user' => $user->getAttributes(), 'wishlists' => $user->wishlists->toArray()]);
     return view('profile', ['user' => $user]);
 }
Example #19
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $users = User::with('roles')->get();
     $roles = Role::all();
     return view('rbac.user')->with(['users' => $users, 'roles' => $roles]);
     // return view('rbac.user');
 }
Example #20
0
 /**
  * Display the specified resource.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     if (Auth::user()->id == $id) {
         return redirect()->route('perfil.edit', $id);
     }
     $usuario = User::with('cursos')->with('laboratorios')->withTrashed()->findOrFail($id);
     return view('usuarios.show', compact('usuario'));
 }
 function getExample5()
 {
     $user_id = 1;
     $user = \App\User::with('peaks')->find($user_id);
     $user_peaks = $user->peaks;
     $count = count($user_peaks);
     dump($count);
 }
Example #22
0
 public function archivedGroup()
 {
     $id = Auth::id();
     $user = User::with(array('groups' => function ($q) {
         $q->where('status', '=', 0);
     }))->where('id', '=', $id)->first();
     return view('groups_archived')->with('user', $user);
 }
Example #23
0
 public function index()
 {
     $users = User::with(['weights' => function ($query) {
         $query->orderBy('created_at', 'desc');
     }])->has('weights')->get();
     $chats = Chat::with('user')->orderBy('created_at', 'desc')->take(15)->get();
     return view('leaderboard')->with('users', $users)->with('chats', $chats);
 }
Example #24
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function adminIndex()
 {
     if (Gate::denies('adminOnly')) {
         abort(403);
     }
     // Retrieve all the users in the database and return them
     return User::with('organization')->get();
 }
Example #25
0
 public function index(Manager $fractal, UserTransformer $userTransformer)
 {
     // show all
     $records = User::with('locations', 'notifications', 'optimizerviewoptions', 'role', 'viewfilters', 'viewoptions')->get();
     $collection = new Collection($records, $userTransformer);
     $data = $fractal->createData($collection)->toArray();
     return $this->respond($data);
 }
 public function index()
 {
     $user = new User();
     $article = new Article();
     $articles = $article->orderBy('updated_at', 'desc')->with('user')->get();
     $users = $user->with('roles')->get();
     return view('articles.articles', compact('articles', 'users'));
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     //
     $contractor = User::with('keys')->findOrFail($id);
     $keys = Key::all();
     $properties = Property::all();
     return View('contractors.show', compact(['contractor', 'keys', 'properties']));
 }
 /**
  * Display the specified resource.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $user = User::with('projects')->where('id', $id)->get()->first();
     if (!$user) {
         return Response::json(['message' => 'Student not found'], 404);
     }
     return Response::json($user);
 }
 /**
  * Default view when managing users through the admin interface
  *
  * @return \Illuminate\View\View
  */
 public function index()
 {
     $users = array();
     foreach (User::with('group')->get() as $user) {
         array_push($users, $user);
     }
     return view('admin.users.index', compact('users'));
 }
Example #30
-9
 public function verCurriculo($id)
 {
     //$resultado="";
     //$userId=\App\Estudante::find($id)->user_id;
     $userId = Auth::user()->estudante->user_id;
     //$estudante=Estudante::all()->where("user_id",$userId);
     //if()
     if ($id == $userId) {
         // echo $id;
         // echo $userId;
         $resultado = User::with(['endereco', 'contacto', 'estudante', 'estudante.curriculo', 'estudante.curriculo.disponibilidade', 'estudante.curriculo.OutraQualificacao', 'estudante.curriculo.referencia', 'estudante.curriculo.HabilitacaoIntelectual', 'estudante.curriculo.habilitacao', 'estudante.curriculo.experiencia', 'estudante.curriculo.Idioma'])->where('id', $userId)->first();
         $parameter = array();
         $parameter['resultado'] = $resultado;
         /* $html=View::make('ApreciarPerfil')->withData($parameter);
                $dompdf=new \DOMPDF();
                $dompdf->set_base_path(public_path().'/Start/css/MeuStyle');//use style exterior
                $dompdf->load_html($html);
                $dompdf->render();
               $dompdf->stream("cv.pdf");
            }*/
         $pdf = \PDF::loadView('ApreciarPerfil', $parameter);
         return $pdf->stream('Curriculum.pdf');
     } else {
         return "nao foi encontrado";
     }
 }