/** * Show the application dashboard to the user. * * @return Response */ public function index(Route $route) { //echo $route->getActionName(); // exit(); $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')); }
/** * function run by server every certain time for logout */ public function outFromSystem() { $now = new DateTime(date("Y-m-d H:i:s")); $userid = Tracklogin::select('userid')->first(); $userId = $userid->userid; $sessiontime = Tracklogin::select('sessiontime')->get()->first(); $date2 = $sessiontime->sessiontime; $date3 = new DateTime($date2); $diff1 = $date3->diff($now); $test = $diff1->s; if ($diff1->s > 2) { //Checking event_id key exist in session. $maxID = DB::table('systemtracks')->max('id'); $eventid = Systemtrack::where('id', $maxID)->pluck('eventid'); $leave_at = Systemtrack::where('id', $maxID)->pluck('leave_at'); if ($eventid != 0 && $leave_at == NULL) { $systemeventid = Systemtrack::where('id', $maxID)->pluck('systemeventid'); $systemtrack = Systemtrack::find($systemeventid); $systemtrack->leave_at = date("Y-m-d H:i:s"); $systemtrack->save(); } //Checking booth_id key exist in session. $maxID = DB::table('systemtracks')->max('id'); $boothid = Systemtrack::where('id', $maxID)->pluck('boothid'); $leave_at = Systemtrack::where('id', $maxID)->pluck('leave_at'); if ($boothid != 0 && $leave_at == Null) { $systemboothid = Systemtrack::where('id', $maxID)->pluck('systemboothid'); $systemtrack = Systemtrack::find($systemboothid); $systemtrack->leave_at = date("Y-m-d H:i:s"); $systemtrack->save(); } $maxLogin = DB::table('tracklogins')->where('user_id', $userId)->max('login_at'); DB::table('tracklogins')->where('user_id', $userId)->where('login_at', $maxLogin)->update(['logout_at' => $now]); //Auth::logout(); } }
public function loginhistoryforall() { // if (!$this->adminAuth()) { return view('errors.404'); } $users = User::all(); $tracklogins = Tracklogin::orderBy('created_at', 'desc')->get(); return view('AdminCP.reports.tracklogins.index', compact('tracklogins', 'users')); }
/** * Get the post register / login redirect path. * * @return string */ public function redirectPath() { // add in tracl login table a record $userId = Auth::user()->id; $tracklogin = new Tracklogin(); $tracklogin->user_id = $userId; $now = new DateTime(); $tracklogin->login_at = $now; $tracklogin->save(); // if (Auth::user()->type == 'company') { // $this->redirectTo='/company'; // return $this->redirectTo; // } if (property_exists($this, 'redirectPath')) { return $this->redirectPath; } return property_exists($this, 'redirectTo') ? $this->redirectTo : '/'; }