session = $this->session_AuthTrait(); $this->class_name = 'Auth'; helper($this->class_name); } final protected function getModel(): AuthModel { if ($this->_model === null) { $this->_model = new AuthModel(); } return $this->_model; } protected function create_form_process(): void { $this->fields = ['id', 'authkey']; $this->filter_fields = ['status']; parent::create_form_process(); } public function create_form(): RedirectResponse|string { try { $this->fields = ['id', 'authkey']; $this->filter_fields = ['status']; $this->action = 'create'; $this->getModel()->setAction($this->action); $this->session->keepFlashdata(SESSION_NAMES['RETURN_URL']); return view("/{$this->class_name}/insert", ['attributes' => $this->getAttributes]); } catch (\Exception $e) { log_message("error", $e->getMessage()); return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/")->with(SESSION_NAMES['RETURN_MSG'], $e->getMessage()); } } protected function create_process($model): AuthEntity { return parent::create_process($model); } public function create(): RedirectResponse { $this->getModel()->transStart(); try { $this->fields = ['id', 'authkey']; $this->filter_fields = ['status']; $this->action = 'create'; $this->getModel()->setAction($this->action); $entity = $this->create_process($this->getModel()); log_message("notice", __FUNCTION__ . "=>{$entity->getTitle()} 작업을 완료하였습니다."); return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/"); } catch (\Exception $e) { //Transaction Rollback $this->getModel()->transRollback(); log_message("error", $e->getMessage()); $this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], __FUNCTION__ . " 실패하였습니다.\n" . $e->getMessage()); $this->session->keepFlashdata(SESSION_NAMES['RETURN_URL']); return redirect()->back()->withInput(); } } }