class_name .= "Record"; $this->layout = LAYOUTS['admin']; $this->title = lang("{$this->class_name}.title"); $this->session = $this->session_AuthTrait(); helper($this->class_name); } final protected function getModel(): RecordModel { if ($this->_model === null) { $this->_model = new RecordModel(); } return $this->_model; } final protected function getAccountModel(): AccountModel { if ($this->_accountModel === null) { $this->_accountModel = new AccountModel(); } return $this->_accountModel; } final protected function getZoneModel(): ZoneModel { if ($this->_zoneModel === null) { $this->_zoneModel = new ZoneModel(); } return $this->_zoneModel; } protected function getFormFieldOption(string $field, array $options = []): array { switch ($field) { case RecordModel::PARENT: $options = [ DEFAULTS['EMPTY'] => lang($this->_className . '.label.' . $field) . ' 선택', ...$this->getZoneModel()->getFilterFieldOption($field, $options) ]; break; default: $options = parent::getFormFieldOption($field, $options); break; } return $options; } protected function create_init(): void { $this->fields = ['id', 'apikey']; $this->filter_fields = ['status']; $this->action = 'create'; $this->getModel()->setAction($this->action); } public function create_form(): RedirectResponse|string { return $this->create_form_process(); } protected function create_process_submit(): RecordEntity { $zone_entity = $this->getZoneModel()->getEntityByPK($this->formDatas[$this->getModel()::PARENT]); $account_entity = $this->getAccountModel()->getEntityByPK($zone_entity->getParent()); $Record = new Record($account_entity, $zone_entity); return $Record->create($this->formDatas); } public function create(): RedirectResponse { return parent::create_process(); } }