/**
  * Get a paginated list of all users
  * 	
  *	@param int $howMany
  * 	
  *	@param string $byKeyword
  *
  *	@return mixed
  */
 public function getPaginated($howMany = 10, $byFirstname = null)
 {
     if (is_null($byFirstname)) {
         return User::whereNotIn('id', [Auth::user()->id])->orderBy('firstname', 'asc')->paginate($howMany);
     }
     return User::whereNotIn('id', [Auth::user()->id])->where('firstname', 'like', '%' . $byFirstname . '%')->orderBy('firstname', 'asc')->paginate($howMany);
 }
 public function index($id)
 {
     $group = Group::findOrFail($id);
     $users = User::whereNotIn('id', $group->users()->get()->map(function ($item, $key) {
         return $item->id;
     }))->get();
     return view('groupUsers', compact('group', 'users'));
 }
Example #3
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $userActive = Auth::user();
     if ($userActive->role == 'admin') {
         $users = User::whereNotIn('role', ['admin'])->get();
     } else {
         $users = User::whereNotIn('role', ['operator', 'admin'])->get();
     }
     return view('users.index', ['users' => $users, 'user' => $userActive]);
 }
 /**
  * Show the Administrator panel.
  *
  * @return \Illuminate\View\View
  */
 public function index()
 {
     try {
         $user = Auth::user()->with('projects')->where('id', '=', '2')->firstOrFail();
     } catch (ModelNotFoundException $e) {
         return Redirect::home();
     }
     // if it's admin, redirect to admin cms with all users but admin
     $allUsers = User::whereNotIn('id', [2])->get();
     $allSponsors = Sponsor::all();
     // Retrieve all projects pending approval.
     $pendingProjects = Project::where('approved', '=', '0')->where('application_status', '=', '1')->where('live', '=', '0')->get();
     return view('adminpanel.index', compact('user', 'allUsers', 'pendingProjects', 'allSponsors'));
 }
Example #5
0
 /**
  * Shows a message thread
  *
  * @param $id
  * @return mixed
  */
 public function show($id)
 {
     try {
         $thread = Thread::findOrFail($id);
     } catch (ModelNotFoundException $e) {
         Session::flash('error_message', 'The thread with ID: ' . $id . ' was not found.');
         return redirect('messages');
     }
     // don't show the current user in list
     $userId = Auth::user()->id;
     $users = User::whereNotIn('id', $thread->participantsUserIds($userId))->get();
     $thread->markAsRead($userId);
     return view('messenger.show', compact('thread', 'users'));
 }
 /**
  * Shows a message thread.
  *
  * @param $id
  * @return mixed
  */
 public function show($subject)
 {
     try {
         $thread = Thread::where('subject', $subject)->first();
     } catch (ModelNotFoundException $e) {
         echo "error";
     }
     // show current user in list if not a current participant
     // $users = User::whereNotIn('id', $thread->participantsUserIds())->get();
     // don't show the current user in list
     $userId = Authorizer::getResourceOwnerId();
     $users = User::whereNotIn('id', $thread->participantsUserIds($userId))->get();
     $thread->markAsRead($userId);
     return $thread->messages;
 }
 /**
  * Shows a message thread
  *
  * Example URL: GET /api/v1/messages/1?api_key=30ce6864e2589b01bc002b03aa6a7923
  *
  * @param MessageTransformer $messageTransformer
  * @param $id
  * @return mixed
  */
 public function show(MessageTransformer $messageTransformer, $id)
 {
     $userId = $this->user->id;
     try {
         $thread = Thread::findOrFail($id);
     } catch (ModelNotFoundException $e) {
         return $this->respondNotFound('Sorry, the message thread was not found.');
     }
     $thread->markAsRead($userId);
     $messageData = $thread->toArray();
     // Get messages
     $messages = $thread->messages()->with('user')->get();
     $messageData['messages'] = $messages->toArray();
     // Get participants
     $participants = User::whereIn('id', $thread->participantsUserIds())->get();
     $messageData['participants'] = $participants->toArray();
     // Get non-participants
     $nonParticipants = User::whereNotIn('id', $thread->participantsUserIds())->get();
     $messageData['non_participants'] = $nonParticipants->toArray();
     $data = $messageTransformer->transform($messageData);
     $response = ['data' => $data];
     return $this->respondWithSuccess($response);
 }
 public function updateThread($id)
 {
     try {
         $thread = Thread::findOrFail($id);
     } catch (ModelNotFoundException $e) {
         Session::flash('error_message', 'The thread with ID: ' . $id . ' was not found.');
         return redirect('messages');
     }
     $thread->activateAllParticipants();
     // Message
     Message::create(['thread_id' => $thread->id, 'user_id' => Auth::id(), 'body' => Input::get('message')]);
     // Add replier as a participant
     $participant = Participant::firstOrCreate(['thread_id' => $thread->id, 'user_id' => Auth::user()->id]);
     $participant->last_read = new Carbon();
     $participant->save();
     // Recipients
     if (Input::has('recipients')) {
         $thread->addParticipants(Input::get('recipients'));
     }
     $userId = Auth::user()->id;
     $users = \App\User::whereNotIn('id', $thread->participantsUserIds($userId))->get();
     return view('messages.show', ['page' => 'message', 'thread' => $thread, 'users' => $users]);
 }
 public function viewUsers()
 {
     $this->authorize('viewAdmin');
     $users_array = User::whereNotIn('id', [1, 4])->get();
     $projects = Project::all();
     //$projects = Project::lists('title','id', 'user');
     //dd($projects_array);
     return view('admin.users', ['users' => $users_array, 'projects' => $projects]);
 }
Example #10
0
 /**
  * Get the users who could be invited into the conversation
  * 
  * @return Collection
  */
 public function getPotentialInvitees()
 {
     $current_participants = $this->participants()->lists('id');
     return \App\User::whereNotIn('id', $current_participants)->get();
 }
 public function editTeam($id)
 {
     if (!$this->auth()) {
         return "You have no Permissions!";
     }
     $team = team::where('teamID', '=', $id)->first();
     $students = team_contents::where('teamID', '=', $id)->get(array('studentID'));
     $s = array();
     foreach ($students as $a) {
         array_push($s, $a->studentID);
     }
     $teamContents = User::whereIn('id', $s)->get();
     $allStudents = User::whereNotIn('id', $s)->get();
     return view('editTeam', compact('team', 'teamContents', 'allStudents'));
 }
 public function getUserinfo(Request $request)
 {
     if ($request->has('s')) {
         $users = $this->returnSearchObj('users', $request->input('s'));
         return view('dashboard.userinfo', ['objs' => $users[0], 'searchStr' => $users[1]]);
     } else {
         $objs = User::whereNotIn('admin', [99])->paginate($this->pg);
         return view('dashboard.userinfo', compact('objs'));
     }
 }
Example #13
0
 /**
  * Get List of all users.
  *
  * @param array $formData search data
  * @return Collection
  */
 public function getAll($id)
 {
     $users = $this->user->whereNotIn('id', [$id]);
     return $users->paginate(1);
 }