passwordLogs = new PasswordLogs; $this->passwordLogs->admin_id = $admin_id; $this->passwordLogs->password = md5($password); $this->passwordLogs->generated_password = $password; $this->passwordLogs->created_by = $created_by; $this->passwordLogs->created_dt = date('Y-m-d H:i:s'); if($is_generated) $this->passwordLogs->is_generated = 1; $this->passwordLogs->save(); } public function getByField($data) { $this->passwordLogs = new PasswordLogs; if(count($data)) { foreach ($data as $field => $value) { $this->passwordLogs = $this->passwordLogs->where($field,$value); } } return $this->passwordLogs->get(); } public function getLastLog($admin_id) { $this->passwordLogs = PasswordLogs::where('admin_id',$admin_id) ->orderBy('created_dt', 'desc') ->first(); return $this->passwordLogs; } }