Beispiel #1
0
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index(Route $route)
 {
     $upcomingexhibitionevents = ExhibitionEvent::where('start_time', '>', date("Y-m-d H:i:s"))->take(4)->get();
     $currentlyexhibitionevents = ExhibitionEvent::where('start_time', '<', date("Y-m-d H:i:s"))->where('end_time', '>', date("Y-m-d H:i:s"))->take(4)->get();
     $tracklogins = Tracklogin::where('user_id', '=', Auth::User()->id)->orderBy('created_at', 'desc')->take(2)->get();
     $systemtracks = Systemtrack::where('user_id', '=', Auth::User()->id)->orderBy('created_at', 'desc')->take(5)->get();
     if (Auth::User()->type == 'company') {
         $user = User::find(Auth::User()->id);
         $company = Company::where('user_id', $user->id)->get();
         $company = $company[0];
         $companyId = $company->id;
         $exhibitors = Exhibitor::where('company_id', $companyId)->get();
         //$booths=array();
         $events = array();
         $i = 0;
         foreach ($exhibitors as $exhibitor) {
             $booths = Booth::where('exhibitor_id', $exhibitor->id)->get();
             foreach ($booths as $booth) {
                 $events[$i] = $booth->exhibition_event_id;
                 $i++;
             }
         }
         $events = array_unique($events);
         //var_dump($events); exit();
         $i = 0;
         $exhibitionevents = array();
         foreach ($events as $event) {
             $exhibitionevents[$i] = ExhibitionEvent::find($event);
             $i++;
         }
         // var_dump($exhibitionevents[0]); exit();
         $upcomingcompanyevents = array();
         $currentlycompanyevents = array();
         $finishedcompanyevents = array();
         $i = 0;
         foreach ($exhibitionevents as $exhibitionevent) {
             if ($exhibitionevent->start_time > date("Y-m-d H:i:s")) {
                 $upcomingcompanyevents[$i] = $exhibitionevent;
                 $i++;
             } elseif ($exhibitionevent->start_time < date("Y-m-d H:i:s") && $exhibitionevent->end_time > date("Y-m-d H:i:s")) {
                 $currentlycompanyevents[$i] = $exhibitionevent;
                 $i++;
             } else {
                 $finishedcompanyevents[$i] = $exhibitionevent;
                 $i++;
             }
         }
     }
     return view('home', compact('upcomingexhibitionevents', 'currentlyexhibitionevents', 'tracklogins', 'systemtracks', 'upcomingcompanyevents', 'currentlycompanyevents', 'finishedcompanyevents'));
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     //
     $v = Validator::make(Request::all(), ['name' => 'required|max:50', 'hall_id' => 'required', 'exhibition_id' => 'required']);
     if ($v->fails()) {
         return redirect()->back()->withErrors($v->errors())->withInput();
     } else {
         $id = Request::get('id');
         $exhibitionevent = ExhibitionEvent::find($id);
         $exhibitionevent->name = Request::get('name');
         $exhibitionevent->desc = Request::get('desc');
         $exhibitionevent->start_time = Request::get('start_time');
         $exhibitionevent->end_time = Request::get('end_time');
         // $exhibitionevent->hall_id = Request::get('hall_id');
         $exhibitionevent->exhibition_id = Request::get('exhibition_id');
         $exhibitionevent->save();
         $exhibitioneventhall = ExhibitionEventHall::find($id);
         $exhibitioneventhall->hall_id = Request::get('hall_id');
         $exhibitioneventhall->save();
         return redirect('exhibitionevents');
     }
 }
 public function bookBooth($id)
 {
     if (!$this->adminAuth() && !$this->checkCompanyType()) {
         return view('errors.404');
     }
     $exhibitioneventId = $id;
     $checExEv = ExhibitionEvent::find($exhibitioneventId);
     if (date("Y-m-d H:i:s") > $checExEv->start_time) {
         return view('errors.404');
     }
     $exhibitors = Exhibitor::all();
     $exhibitionevents = ExhibitionEvent::all();
     $types = Type::all();
     $models = Modeldesign::all();
     $spots = Spot::all();
     return view('CompanyCP.booths.create', compact('types', 'models', 'exhibitors', 'exhibitionevents', 'exhibitioneventId', 'spots'));
 }
 /**
  * function to show event in certain page
  *
  * @param  int  $id
  * @return Response
  */
 public function showEventPage($id)
 {
     //check on event_id is exsist
     if (Session::has('systemtrack_event_id')) {
         $systemtrack_event_id_value = Session::get('systemtrack_event_id');
         $systemtrack_event = Systemtrack::find($systemtrack_event_id_value);
         if ($systemtrack_event->leave_at == null) {
             DB::table('systemtracks')->where('id', $systemtrack_event_id_value)->update(['leave_at' => date("Y-m-d H:i:s")]);
             //$systemtrack_booth->leave_at=date("Y-m-d H:i:s");
         }
     }
     //check on booth_id is exsist
     if (Session::has('systemtrack_booth_id')) {
         $systemtrackid = Systemtrack::all()->last()->pluck('id');
         $systemtrack_booth_id_value = Session::get('systemtrack_booth_id');
         $systemtrack_booth = Systemtrack::find($systemtrack_booth_id_value);
         if ($systemtrack_booth->leave_at == null) {
             DB::table('systemtracks')->where('id', $systemtrack_booth_id_value)->update(['leave_at' => date("Y-m-d H:i:s")]);
             //$systemtrack_booth->leave_at=date("Y-m-d H:i:s");
         }
     }
     $exhibitionevent = ExhibitionEvent::find($id);
     $booths = Booth::where('exhibition_event_id', $id)->get();
     $systemtrack = new Systemtrack();
     $systemtrack->user_id = Auth::User()->id;
     //  $systemtrack->spot_id=$booth->spot_id;
     $systemtrack->do = Auth::User()->name . ' ' . 'visit' . ' ' . $exhibitionevent->name . ' Event ' . 'at' . ' ' . date("Y-m-d H:i:s");
     $systemtrack->comein_at = date("Y-m-d H:i:s");
     $systemtrack->type = 'exhibitionevent';
     $systemtrack->type_id = $id;
     $systemtrack->save();
     //save  exhibition event id  in session
     Session::put('event_id', $id);
     Session::put('systemtrack_event_id', $systemtrack->id);
     DB::table('systemtracks')->where('id', $systemtrack->id)->update(['eventid' => $id, 'systemeventid' => $systemtrack->id]);
     return view('exhibitionevents.eventpage', compact('exhibitionevent', 'booths'));
 }