Example #1
0
 function getTask()
 {
     $user = \Auth::user();
     $events = Event::all();
     $event = Event::latest('id')->first();
     $tasks = Task::all();
     $categories = array('Pending', 'In-progress', 'Delayed', 'Finished');
     //Array of head->id of user
     $heads_comm = Head::where('event_id', $event->id)->where('user_id', $user->id)->get(array('comm_id'))->toArray();
     //members of committee
     $mem = Member::whereIn('comm_id', $heads_comm)->get(array('user_id'))->toArray();
     $members = User::whereIn('id', $mem)->get();
     //committees where user is head
     $committees = Committee::whereIn('id', $heads_comm)->get();
     return view('pages/task', compact('user', 'members', 'events', 'event', 'committees', 'tasks', 'categories'));
 }
 public function getId($id)
 {
     $users = User::all();
     $user = $this->getUser();
     $curr_event = Event::where('id', $id)->first();
     $all_comm = Committee::all();
     $committees = Committee::where('event_id', $curr_event->id)->get();
     $comm_array = Committee::where('event_id', $curr_event->id)->get(array('id'))->toArray();
     $events = Event::all();
     $tasks = Task::where('assigned_to', $user['id'])->whereIn('comm_id', $comm_array)->get();
     //tasks assigned to current user
     $all_tasks = Task::all();
     $categories = array('Pending', 'In-progress', 'Delayed', 'Finished');
     $comments = Comment::all();
     //get current event id
     $curr_event_id = $curr_event->id;
     //check if current user is upper head
     //get all heads of current event
     $heads = Head::where('event_id', $curr_event_id)->where('user_id', $user->id)->get();
     //get all comm_id(as array) in the current event where current user is a head
     $heads_comm = Head::where('event_id', $curr_event_id)->where('user_id', $user['id'])->get(array('comm_id'))->toArray();
     //members of committee
     $mem = Member::whereIn('comm_id', $heads_comm)->get(array('user_id'))->toArray();
     $members = User::whereIn('id', $mem)->get();
     //get all committees in the current event where current user is a head
     $head_committees = Committee::whereIn('id', $heads_comm)->get();
     //current user is a head
     $heads_comm = Head::where('user_id', $user['id'])->get();
     //committees where current user is a member
     $mem_comm = Member::where('user_id', $user['id'])->get();
     $url = "pages/profile";
     //check if curret user is admin
     if ($user->id == 1) {
         return redirect('/admin/');
     }
     //check if current user is OAH
     if ($curr_event->oah_id == $user->id) {
         $url = "pages/oah";
     }
     //return heads page if user is lower head
     if ($heads != "[]") {
         $url = "pages/heads";
     }
     if ($user->standing == "unconfirmed") {
         $url = "pages/oops";
     }
     echo $url;
     return view($url, compact('users', 'user', 'events', 'curr_event', 'all_comm', 'committees', 'tasks', 'all_tasks', 'categories', 'comments', 'head_committees', 'heads_comm', 'mem_comm', 'members'));
 }