Beispiel #1
0
 public function loadUserLog(Request $request)
 {
     $data = $request->all();
     $date_from = \Helper::parseDate($data['DATE_FROM']);
     $date_to = \Helper::parseDate($data['DATE_TO']);
     $username = trim($data['USERNAME']);
     $result = array();
     $logUser = LogUser::getTableName();
     $loadUserLog = DB::table($logUser . ' AS a')->whereDate('a.LOGIN_TIME', '>=', $date_from)->whereDate('a.LOGIN_TIME', '<=', $date_to)->where(function ($q) use($username) {
         if ($username != "All") {
             $q->where(['a.USERNAME' => $username]);
         }
     })->select(['a.USERNAME', 'a.LOGIN_TIME', 'a.LOGOUT_TIME', 'a.IP'])->get();
     return response()->json(array('result' => $loadUserLog));
 }
Beispiel #2
0
 public function updateLoginLog()
 {
     $attributes = ['SESSION_ID' => session()->getId()];
     $logUser = LogUser::firstOrNew($attributes);
     $values = ['USERNAME' => $this->username, 'LOGIN_TIME' => Carbon::now(), 'IP' => request()->ip(), 'SESSION_ID' => session()->getId()];
     $logUser->fill($values)->save();
 }