modules = [ 'LOGIN' => 'Login', 'OTP' => 'OTP', 'PROFILE' => 'OTP', 'STATIONLOCATOR' => 'Station Locator', 'FUELTRACKER' => 'FUELTRACKER', 'TRANSACTIONS' => 'Transactions', 'RATINGS' => 'Ratings', 'PAYMENTS' => 'Payment', 'SHAREDTREATS' => 'SHAREDTREATS', 'CRONJOB' => 'CRONJOB', 'SIGNUP' => 'Sign Up', ]; $this->actions = [ 'STORE' => 'store', 'UPDATE' => 'update', 'DELETE' => 'delete', 'VIEW' => 'view', 'ACTIVATE' => 'activate', 'GENERATE' => 'generate', 'EXPORT' => 'export', 'LOGIN' => 'login', 'LOGOUT' => 'logout', 'ATTEMPT' => 'attempt', 'LOCKED' => 'locked', 'SEARCH' => 'search', 'INACTIVE' => 'inactive', ]; } public function getByField($field,$value) { $this->lcardActionLogs = LcardActionLogs::where($field,$value) ->orderBy('created_dt','desc'); return $this->lcardActionLogs->get(); } public function log($id, $module, $action, $remarks = '') { if(isset($this->modules[$module]) && isset($this->actions[$action])) { $currentUser = CurrentUserHelper::get_currentMember(); $this->lcardActionLogs = new LcardActionLogs; $this->lcardActionLogs->id = $id; $this->lcardActionLogs->module = $this->modules[$module]; $this->lcardActionLogs->action = $this->actions[$action]; $this->lcardActionLogs->created_by = isset( $currentUser ) ? $currentUser->lcard_id : $id; if($remarks != '') $this->lcardActionLogs->remarks = $remarks; if ($this->lcardActionLogs->save()) { return true; } } return false; } public function getByFieldWithOperator($field, $operator, $value) { $this->lcardActionLogs = LcardActionLogs::selectRaw('*, max(lactivity_id) as last') ->where($field,$value) ->groupBy('created_at')->orderBy('created_at','desc'); return $this->lcardActionLogs->get(); } }