class_name = "UserSNS"; $this->class_path .= $this->class_name; $this->title = lang("{$this->class_path}.title"); $this->helper = new UserSNSHelper(); } protected function getModel(): UserSNSModel { if ($this->_model === null) { $this->_model = new UserSNSModel(); } return $this->_model; } protected function setFormFieldRule($field, Validation $validation, string $action): Validation { switch ($field) { default: $validation = parent::setFormFieldRule($field, $validation, $action); break; } return $validation; } protected function getFormFieldOption(string $field, array $options = []): array { switch ($field) { case $this->getModel()::PARENT: $userModel = model(UserModel::class); // $this->getUserModel()->where('status', DEFAULTS['STATUS']); $options[$field] = $userModel->getFormFieldOption($field); // echo $this->getUserModel()->getLastQuery(); // dd($options); break; default: $options = parent::getFormFieldOption($field, $options); break; } return $options; } protected function getFormData(string $field, array $formDatas): array { switch ($field) { default: $formDatas = parent::getFormData($field, $formDatas); break; } return $formDatas; } private function init(string $action): void { $this->action = $action; $this->fields = [$this->getModel()::PARENT, 'site', 'id', $this->getModel()::TITLE, 'email']; $this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields); $this->filter_fields = [$this->getModel()::PARENT, 'status']; $this->field_options = $this->getFormFieldOptions($this->filter_fields); } //수정 public function modify_form(string $uid): RedirectResponse|string { $this->init('modify'); return $this->modify_form_procedure($uid); } public function modify(string $uid): RedirectResponse|string { $this->init(__FUNCTION__); return $this->modify_procedure($uid); } //일괄작업 public function batcjob(): RedirectResponse { $this->action = __FUNCTION__; $this->fields = ['status']; $this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields); return $this->batcjob_procedure(); } // 리스트 public function index(): string { $this->action = __FUNCTION__; $this->fields = [$this->getModel()::PARENT, 'site', 'id', $this->getModel()::TITLE, 'email', 'status']; $this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields); $this->filter_fields = [$this->getModel()::PARENT, 'status']; $this->field_options = $this->getFormFieldOptions($this->filter_fields); $this->batchjob_fields = []; return $this->list_procedure(); } // Download public function download(string $output_type, $uid = false): DownloadResponse|string { $this->action = __FUNCTION__; $this->fields = [$this->getModel()::PARENT, 'site', 'id', $this->getModel()::TITLE, 'email', 'status']; $this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields); $this->filter_fields = [$this->getModel()::PARENT, 'status']; $this->field_options = $this->getFormFieldOptions($this->filter_fields); $this->batchjob_fields = []; return $this->download_procedure($output_type, $uid); } }