diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 829b731..d36c29f 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -130,7 +130,7 @@ $routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($rou $routes->get('excel', 'ProductController::excel/$1'); $routes->get('view/(:uuid)', 'ProductController::view/$1'); }); - $routes->group('order', ['namespace' => 'App\Controllers\Front', 'filter' => 'authFilter:master,director,cloudflare,manager,gold,silver,brone,vip,user'], static function ($routes) { + $routes->group('order', static function ($routes) { $routes->get('', 'OrderController::index'); $routes->post('insert', 'OrderController::insert'); $routes->get('view/(:uuid)', 'OrderController::view/$1'); diff --git a/app/Controllers/Admin/BoardConfigController.php b/app/Controllers/Admin/BoardConfigController.php index 6cdd919..c675803 100644 --- a/app/Controllers/Admin/BoardConfigController.php +++ b/app/Controllers/Admin/BoardConfigController.php @@ -17,4 +17,35 @@ class BoardConfigController extends AdminController $this->_viewPath .= strtolower($this->_model->getClassName()); helper($this->_model->getClassName()); } + + public function getFields(string $action = ""): array + { + $fields = [ + 'name', "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload", + "status", "head", "tail", + ]; + switch ($action) { + case "index": + case "excel": + return [ + 'name', "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload", + "status", "created_at" + ]; + break; + case "view": + return [...$fields, "updated_at", "created_at"]; + break; + default: + return $fields; + break; + } + } + public function getFieldFilters(): array + { + return ["isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload", "status"]; + } + public function getFieldBatchFilters(): array + { + return parent::getFieldBatchFilters(); + } } diff --git a/app/Controllers/Admin/BoardController.php b/app/Controllers/Admin/BoardController.php index e17b737..ed71d02 100644 --- a/app/Controllers/Admin/BoardController.php +++ b/app/Controllers/Admin/BoardController.php @@ -6,18 +6,43 @@ use App\Models\BoardModel; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; +use App\Models\BoardConfigModel; class BoardController extends AdminController { public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { - $this->_model = new BoardModel(); + $this->_model = new BoardModel($this->getFields()); parent::initController($request, $response, $logger); $this->_viewDatas['title'] = lang($this->_model->getClassName() . '.title'); $this->_viewPath .= strtolower($this->_model->getClassName()); helper($this->_model->getClassName()); } + public function getFields(string $action = ""): array + { + $fields = ["board_config_uid", 'title', "board_file", "passwd", "status", "content"]; + switch ($action) { + case "index": + case "excel": + return ["board_config_uid", "user_uid", 'title', "board_file", "view_cnt", "status", "created_at"]; + break; + case "view": + return ["board_config_uid", "user_uid", 'title', "board_file", "view_cnt", "status", "created_at", "content"]; + break; + default: + return $fields; + break; + } + } + public function getFieldFilters(): array + { + return ["board_config_uid", "user_uid", "status"]; + } + public function getFieldBatchFilters(): array + { + return parent::getFieldBatchFilters(); + } //Field별 Form Datas 처리용 protected function getFieldFormData(string $field, $entity = null): array { diff --git a/app/Controllers/Admin/CategoryController.php b/app/Controllers/Admin/CategoryController.php index 3d27c8d..4f57910 100644 --- a/app/Controllers/Admin/CategoryController.php +++ b/app/Controllers/Admin/CategoryController.php @@ -17,4 +17,28 @@ class CategoryController extends AdminController $this->_viewPath .= strtolower($this->_model->getClassName()); helper($this->_model->getClassName()); } + public function getFields(string $action = ""): array + { + $fields = ['name', "status", "head", "tail",]; + switch ($action) { + case "index": + case "excel": + return ['name', "status", "created_at"]; + break; + case "view": + return ['name', "status", "created_at", "head", "tail",]; + break; + default: + return $fields; + break; + } + } + public function getFieldFilters(): array + { + return ["status"]; + } + public function getFieldBatchFilters(): array + { + return parent::getFieldBatchFilters(); + } } diff --git a/app/Controllers/Admin/OrderController.php b/app/Controllers/Admin/OrderController.php index 8cc2513..10fd59a 100644 --- a/app/Controllers/Admin/OrderController.php +++ b/app/Controllers/Admin/OrderController.php @@ -2,22 +2,43 @@ namespace App\Controllers\Admin; -use App\Entities\OrderEntity; use App\Models\OrderModel; -use App\Models\ProductModel; -use CodeIgniter\Cookie\Exceptions\CookieException; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; class OrderController extends AdminController { + private $_product_options = null; public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { - $this->_model = new OrderModel(); + $this->_model = new OrderModel($this->getFields()); parent::initController($request, $response, $logger); $this->_viewDatas['title'] = lang($this->_model->getClassName() . '.title'); $this->_viewPath .= strtolower($this->_model->getClassName()); helper($this->_model->getClassName()); } + + final public function getFields(string $action = ""): array + { + $fields = ['product_uid', "quantity", "price", "status"]; + switch ($action) { + case "index": + case "excel": + case "view": + return ['product_uid', "user_uid", "quantity", "price", "status", "updated_at", "created_at"]; + break; + default: + return $fields; + break; + } + } + final public function getFieldFilters(): array + { + return ['product_uid', "user_uid", "status"]; + } + final public function getFieldBatchFilters(): array + { + return ["status"]; + } } diff --git a/app/Controllers/Admin/ProductController.php b/app/Controllers/Admin/ProductController.php index 6a9a3a1..986935d 100644 --- a/app/Controllers/Admin/ProductController.php +++ b/app/Controllers/Admin/ProductController.php @@ -6,19 +6,43 @@ use App\Models\ProductModel; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; +use App\Models\CategoryModel; class ProductController extends AdminController { - public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { - $this->_model = new ProductModel(); + $this->_model = new ProductModel($this->getFields()); parent::initController($request, $response, $logger); $this->_viewDatas['title'] = lang($this->_model->getClassName() . '.title'); $this->_viewPath .= strtolower($this->_model->getClassName()); helper($this->_model->getClassName()); } + public function getFields(string $action = ""): array + { + $fields = ["category_uid", 'name', "photo", "cost", "price", "sale", "stock", "view_cnt", "status", "content",]; + switch ($action) { + case "index": + case "excel": + return ["category_uid", "user_uid", 'name', "photo", "cost", "price", "sale", "stock", "view_cnt", "status", "created_at"]; + break; + case "view": + return [...$fields, "created_at"]; + break; + default: + return $fields; + break; + } + } + public function getFieldFilters(): array + { + return ["category_uid", "user_uid", "status"]; + } + public function getFieldBatchFilters(): array + { + return parent::getFieldBatchFilters(); + } //Field별 Form Datas 처리용 protected function getFieldFormData(string $field, $entity = null): array { diff --git a/app/Controllers/Admin/UserController.php b/app/Controllers/Admin/UserController.php index 9c1bb78..2f535c6 100644 --- a/app/Controllers/Admin/UserController.php +++ b/app/Controllers/Admin/UserController.php @@ -11,7 +11,7 @@ class UserController extends AdminController { public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { - $this->_model = new UserModel(); + $this->_model = new UserModel($this->getFields()); parent::initController($request, $response, $logger); $this->_viewDatas['title'] = lang($this->_model->getClassName() . '.title'); $this->_viewPath .= strtolower($this->_model->getClassName()); @@ -32,4 +32,29 @@ class UserController extends AdminController } return $this->_viewDatas['fieldDatas']; } + + public function getFields(string $action = ""): array + { + $fields = ["id", "passwd", $this->_model->getTitleField(), "email", "role", "status"]; + switch ($action) { + case "index": + case "excel": + return ["id", $this->_model->getTitleField(), "email", "role", "status", 'created_at']; + break; + case "view": + return ["id", $this->_model->getTitleField(), "email", "role", "status", 'updated_at', 'created_at']; + break; + default: + return $fields; + break; + } + } + public function getFieldFilters(): array + { + return ["role", "status"]; + } + public function getFieldBatchFilters(): array + { + return parent::getFieldBatchFilters(); + } } diff --git a/app/Controllers/Admin/UserSNSController.php b/app/Controllers/Admin/UserSNSController.php index 3352e93..a12723b 100644 --- a/app/Controllers/Admin/UserSNSController.php +++ b/app/Controllers/Admin/UserSNSController.php @@ -17,4 +17,28 @@ class UserSNSController extends AdminController $this->_viewPath .= strtolower($this->_model->getClassName()); helper($this->_model->getClassName()); } + public function getFields(string $action = ""): array + { + $fields = ["site", "id", $this->_model->getTitleField(), "email", "detail", "status"]; + switch ($action) { + case "index": + case "excel": + return ["user_uid", "site", "id", $this->_model->getTitleField(), "email", "status", "created_at"]; + break; + case "view": + return [...$fields, "updated_at", "created_at"]; + break; + default: + return $fields; + break; + } + } + public function getFieldFilters(): array + { + return ["user_uid", "status"]; + } + public function getFieldBatchFilters(): array + { + return parent::getFieldBatchFilters(); + } } diff --git a/app/Controllers/AuthController.php b/app/Controllers/AuthController.php index 02843e4..e0f481b 100644 --- a/app/Controllers/AuthController.php +++ b/app/Controllers/AuthController.php @@ -2,19 +2,52 @@ namespace App\Controllers; -use App\Libraries\Adapter\Auth\Adapter; +use CodeIgniter\Controller; +use CodeIgniter\HTTP\CLIRequest; +use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; +use App\Libraries\Adapter\Auth\Adapter; -class AuthController extends BaseController + +class AuthController extends Controller { + /** + * Instance of the main Request object. + * + * @var CLIRequest|IncomingRequest + */ + protected $request; + + /** + * An array of helpers to be loaded automatically upon + * class instantiation. These helpers will be available + * to all other controllers that extend BaseController. + * + * @var array + */ + protected $helpers = ['Common']; + + /** + * Be sure to declare properties for any property fetch you initialized. + * The creation of dynamic property is deprecated in PHP 8.2. + */ + // protected $session; + + /** + * Constructor. + */ + private $_session = null; + private $_viewDatas = array(); private $_adapters = array(); public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { parent::initController($request, $response, $logger); + $this->_session = \Config\Services::session(); $this->_viewDatas['title'] = 'Auth'; - $this->_viewPath .= 'auth'; + $this->_viewDatas['layout'] = LAYOUTS['empty']; + $this->_viewDatas['session'] = $this->_session; $this->initAdapters(); } diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php index ddd4650..f99cc01 100644 --- a/app/Controllers/BaseController.php +++ b/app/Controllers/BaseController.php @@ -10,6 +10,7 @@ use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; +use App\Models\UserModel; /** * Class BaseController @@ -63,6 +64,12 @@ abstract class BaseController extends Controller $this->_viewDatas['session'] = $this->_session; } + abstract public function getFields(string $action): array; + abstract public function getFieldFilters(): array; + public function getFieldBatchFilters(): array + { + return $this->getFieldFilters(); + } //Field별 Form Datas 처리용 protected function getFieldFormData(string $field, $entity = null): array { @@ -119,10 +126,10 @@ abstract class BaseController extends Controller $action = 'update'; break; } - $this->_viewDatas['fields'] = $fields ?: $this->_model->getFields($action); + $this->_viewDatas['fields'] = $fields ?: $this->getFields($action); + $this->_viewDatas['fieldFilters'] = $this->getFieldFilters(); + $this->_viewDatas['batchjobFilters'] = $this->getFieldBatchFilters(); $this->_viewDatas['fieldRules'] = $this->_model->getFieldRules($this->_viewDatas['fields'], $action); - $this->_viewDatas['fieldFilters'] = $this->_model->getFieldFilters(); - $this->_viewDatas['batchjobFilters'] = $this->_model->getFieldBatchFilters(); $this->_viewDatas['fieldFormOptions'] = $this->_model->getFieldFormOptions($this->_viewDatas['fieldFilters']); return $this->_viewDatas; } diff --git a/app/Controllers/Front/BoardController.php b/app/Controllers/Front/BoardController.php new file mode 100644 index 0000000..cb463e6 --- /dev/null +++ b/app/Controllers/Front/BoardController.php @@ -0,0 +1,63 @@ +_model = new BoardModel($this->getFields()); + parent::initController($request, $response, $logger); + $this->_viewDatas['title'] = lang($this->_model->getClassName() . '.title'); + $this->_viewPath .= strtolower($this->_model->getClassName()); + helper($this->_model->getClassName()); + } + + public function getFields(string $action = ""): array + { + $fields = ["board_config_uid", 'title', "board_file", "passwd", "status", "content"]; + switch ($action) { + case "index": + case "excel": + return ["board_config_uid", "user_uid", 'title', "board_file", "view_cnt", "status", "created_at"]; + break; + case "view": + return ["board_config_uid", "user_uid", 'title', "board_file", "view_cnt", "status", "created_at", "content"]; + break; + default: + return $fields; + break; + } + } + public function getFieldFilters(): array + { + return ["board_config_uid", "user_uid", "status"]; + } + public function getFieldBatchFilters(): array + { + return parent::getFieldBatchFilters(); + } + //Field별 Form Datas 처리용 + protected function getFieldFormData(string $field, $entity = null): array + { + switch ($field) { + case 'passwd': + $this->_viewDatas['fieldDatas'][$field] = $this->request->getVar($field); + $this->_viewDatas['fieldDatas']['confirmpassword'] = $this->request->getVar('confirmpassword'); + break; + case 'board_file': + $this->_viewDatas['fieldDatas'][$field] = $this->single_upload_procedure($field, $entity); + break; + default: + return parent::getFieldFormData($field, $entity); + break; + } + return $this->_viewDatas['fieldDatas']; + } +} diff --git a/app/Controllers/Front/FrontController.php b/app/Controllers/Front/FrontController.php index 12e8a62..dbdf323 100644 --- a/app/Controllers/Front/FrontController.php +++ b/app/Controllers/Front/FrontController.php @@ -7,7 +7,7 @@ use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; -class FrontController extends BaseController +abstract class FrontController extends BaseController { public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { diff --git a/app/Controllers/Front/OrderController.php b/app/Controllers/Front/OrderController.php index e6894f0..64c4aa3 100644 --- a/app/Controllers/Front/OrderController.php +++ b/app/Controllers/Front/OrderController.php @@ -17,7 +17,7 @@ class OrderController extends FrontController private $_cart_cookie_expire = 3600; //1Hour public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { - $this->_model = new OrderModel(); + $this->_model = new OrderModel($this->getFields()); parent::initController($request, $response, $logger); $this->_viewDatas['title'] = lang($this->_model->getClassName() . '.title'); $this->_viewPath .= strtolower($this->_model->getClassName()); @@ -25,6 +25,29 @@ class OrderController extends FrontController helper('cookie'); } + final public function getFields(string $action = ""): array + { + $fields = ['product_uid', "quantity", "price", "status"]; + switch ($action) { + case "index": + case "excel": + case "view": + return ['product_uid', "user_uid", "quantity", "price", "status", "updated_at", "created_at"]; + break; + default: + return $fields; + break; + } + } + final public function getFieldFilters(): array + { + return ['product_uid', "user_uid", "status"]; + } + final public function getFieldBatchFilters(): array + { + return ["status"]; + } + //쿠키에 장바구니에 담긴 Order UID를 추가해준다. private function setOrderCookie(OrderEntity $entity) { diff --git a/app/Controllers/Front/ProductController.php b/app/Controllers/Front/ProductController.php index b6137c8..7e023ee 100644 --- a/app/Controllers/Front/ProductController.php +++ b/app/Controllers/Front/ProductController.php @@ -9,7 +9,6 @@ use Psr\Log\LoggerInterface; class ProductController extends FrontController { - public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { $this->_model = new ProductModel(); @@ -19,6 +18,30 @@ class ProductController extends FrontController helper($this->_model->getClassName()); } + public function getFields(string $action = ""): array + { + $fields = ["category_uid", 'name', "photo", "cost", "price", "sale", "stock", "view_cnt", "status", "content",]; + switch ($action) { + case "index": + case "excel": + return ["category_uid", "user_uid", 'name', "photo", "cost", "price", "sale", "stock", "view_cnt", "status", "created_at"]; + break; + case "view": + return [...$fields, "created_at"]; + break; + default: + return $fields; + break; + } + } + public function getFieldFilters(): array + { + return ["category_uid", "user_uid", "status"]; + } + public function getFieldBatchFilters(): array + { + return parent::getFieldBatchFilters(); + } //Field별 Form Datas 처리용 protected function getFieldFormData(string $field, $entity = null): array { diff --git a/app/Models/BaseModel.php b/app/Models/BaseModel.php index d35cc11..729f358 100644 --- a/app/Models/BaseModel.php +++ b/app/Models/BaseModel.php @@ -40,8 +40,8 @@ abstract class BaseModel extends Model protected $beforeDelete = []; protected $afterDelete = []; - private $_className = null; private $_user_options = null; + private $_className = null; protected $_session = null; protected function __construct(string $className) { @@ -64,8 +64,6 @@ abstract class BaseModel extends Model } abstract public function getTitleField(): string; abstract public function getEntity($conditions): BaseEntity; - abstract public function getFieldFilters(): array; - abstract public function getFields(string $action): array; final public function getEntitys(array $conditions = array()): array { return $this->where($conditions)->findAll(); @@ -113,11 +111,6 @@ abstract class BaseModel extends Model } return $rules; } - public function getFieldBatchFilters(): array - { - return $this->getFieldFilters(); - } - //Field별 Form Option용 public function getFormOptions(array $conditions = array(), $options = array()): array { @@ -131,17 +124,17 @@ abstract class BaseModel extends Model switch ($field) { case 'user_uid': if (is_null($this->_user_options)) { - $userModel = new UserModel(); - $this->_user_options = $userModel->getFormOptions(['status' => 'use']); + $userModel = new UserModel([$this->getPrimaryKey(), $this->getTitleField()]); + $this->_user_options = $userModel->getFormOptions(); } $options = $this->_user_options; break; default: - $options = lang($this->_className . '.' . strtoupper($field)); + $options = lang($this->getClassName() . '.' . strtoupper($field)); break; } if (!is_array($options)) { - throw new \Exception(__FUNCTION__ . "에서 {$this->_className}의 Field:{$field}의 FormOptionData가 array가 아닙니다.\n" . var_export($options, true)); + throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 Field:{$field}의 FormOptionData가 array가 아닙니다.\n" . var_export($options, true)); } return $options; } @@ -151,7 +144,7 @@ abstract class BaseModel extends Model $fieldFormOptions = array(); foreach ($fields as $field) { if (!is_string($field)) { - throw new \Exception(__FUNCTION__ . "에서 {$this->_className}의 Field:{$field}가 string 아닙니다.\n" . var_export($fields, true)); + throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 Field:{$field}가 string 아닙니다.\n" . var_export($fields, true)); } $fieldFormOptions[$field] = $this->getFieldFormOption($field); } diff --git a/app/Models/BoardConfigModel.php b/app/Models/BoardConfigModel.php index a65c331..88f0cc8 100644 --- a/app/Models/BoardConfigModel.php +++ b/app/Models/BoardConfigModel.php @@ -9,46 +9,16 @@ class BoardConfigModel extends BaseModel protected $table = "tw_board_config"; protected $useAutoIncrement = false; protected $returnType = BoardConfigEntity::class; - public function __construct() + public function __construct(array $fields = array()) { parent::__construct('BoardConfig'); - $this->allowedFields = [...$this->allowedFields, ...$this->getFields()]; + $this->allowedFields = [...$this->allowedFields, ...$fields]; $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; } public function getTitleField(): string { return 'name'; } - public function getFields(string $action = ""): array - { - $fields = [ - $this->getTitleField(), "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload", - "status", "head", "tail", - ]; - switch ($action) { - case "index": - case "excel": - return [ - $this->getTitleField(), "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload", - "status", "created_at" - ]; - break; - case "view": - return [...$fields, "updated_at", "created_at"]; - break; - default: - return $fields; - break; - } - } - public function getFieldFilters(): array - { - return ["isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload", "status"]; - } - public function getFieldBatchFilters(): array - { - return parent::getFieldBatchFilters(); - } protected function getFieldRule(string $field, array $rules, string $action = ""): array { switch ($field) { diff --git a/app/Models/BoardModel.php b/app/Models/BoardModel.php index e7516cf..fcabcde 100644 --- a/app/Models/BoardModel.php +++ b/app/Models/BoardModel.php @@ -9,10 +9,10 @@ class BoardModel extends BaseHierarchyModel private $_boardconfig_options = null; protected $table = "tw_board"; protected $returnType = BoardEntity::class; - public function __construct() + public function __construct(array $fields = array()) { parent::__construct('Board'); - $this->allowedFields = [...$this->allowedFields, ...$this->getFields(), "user_uid"]; + $this->allowedFields = [...$this->allowedFields, "user_uid", ...$fields]; $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; } public function getTitleField(): string @@ -23,30 +23,6 @@ class BoardModel extends BaseHierarchyModel { return 'content'; } - public function getFields(string $action = ""): array - { - $fields = ["board_config_uid", $this->getTitleField(), "board_file", "passwd", "status", "content"]; - switch ($action) { - case "index": - case "excel": - return ["board_config_uid", "user_uid", $this->getTitleField(), "board_file", "view_cnt", "status", "created_at"]; - break; - case "view": - return ["board_config_uid", "user_uid", $this->getTitleField(), "board_file", "view_cnt", "status", "created_at", "content"]; - break; - default: - return $fields; - break; - } - } - public function getFieldFilters(): array - { - return ["board_config_uid", "user_uid", "status"]; - } - public function getFieldBatchFilters(): array - { - return parent::getFieldBatchFilters(); - } protected function getFieldRule(string $field, array $rules, string $action = ""): array { switch ($field) { @@ -75,7 +51,7 @@ class BoardModel extends BaseHierarchyModel switch ($field) { case 'board_config_uid': if (is_null($this->_boardconfig_options)) { - $boardConfigModel = new BoardConfigModel(); + $boardConfigModel = new BoardConfigModel([$this->getPrimaryKey(), $this->getTitleField()]); $this->_boardconfig_options = $boardConfigModel->getFormOptions(); } $options = $this->_boardconfig_options; @@ -85,11 +61,10 @@ class BoardModel extends BaseHierarchyModel break; } if (!is_array($options)) { - throw new \Exception(__FUNCTION__ . "에서 {$this->_className}의 Field:{$field}의 FormOptionData가 array가 아닙니다.\n" . var_export($options, true)); + throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 Field:{$field}의 FormOptionData가 array가 아닙니다.\n" . var_export($options, true)); } return $options; } - public function getEntity($conditions): BoardEntity { return $this->where($conditions)->first() ?: throw new \Exception("해당 데이터가 없습니다.\n" . var_export($conditions, true)); diff --git a/app/Models/CategoryModel.php b/app/Models/CategoryModel.php index 29ab188..72a81da 100644 --- a/app/Models/CategoryModel.php +++ b/app/Models/CategoryModel.php @@ -9,10 +9,10 @@ class CategoryModel extends BaseHierarchyModel //BaseHierarchyModel를 확장하면 grpno가 숫자이고, primarykey를 대분류 생성시 copy하여 grpno에 넣고 sorting하므로 protected $table = "tw_category"; protected $returnType = CategoryEntity::class; - public function __construct() + public function __construct(array $fields = array()) { parent::__construct('Category'); - $this->allowedFields = [...$this->allowedFields, ...$this->getFields(),]; + $this->allowedFields = [...$this->allowedFields, ...$fields]; $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; } public function getTitleField(): string @@ -23,30 +23,6 @@ class CategoryModel extends BaseHierarchyModel { return 'head'; } - public function getFields(string $action = ""): array - { - $fields = [$this->getTitleField(), "status", "head", "tail",]; - switch ($action) { - case "index": - case "excel": - return [$this->getTitleField(), "status", "created_at"]; - break; - case "view": - return [$this->getTitleField(), "status", "created_at", "head", "tail",]; - break; - default: - return $fields; - break; - } - } - public function getFieldFilters(): array - { - return ["status"]; - } - public function getFieldBatchFilters(): array - { - return parent::getFieldBatchFilters(); - } protected function getFieldRule(string $field, array $rules, string $action = ""): array { switch ($field) { diff --git a/app/Models/OrderModel.php b/app/Models/OrderModel.php index 481a157..9d8b0fd 100644 --- a/app/Models/OrderModel.php +++ b/app/Models/OrderModel.php @@ -3,7 +3,6 @@ namespace App\Models; use App\Entities\OrderEntity; -use App\Entities\ProductEntity; class OrderModel extends BaseModel { @@ -12,38 +11,16 @@ class OrderModel extends BaseModel protected $useAutoIncrement = false; protected $returnType = OrderEntity::class; protected $useSoftDeletes = true; - public function __construct() + public function __construct(array $fields = array()) { parent::__construct('Order'); - $this->allowedFields = ["uid", "user_uid", ...$this->allowedFields, ...$this->getFields(),]; + $this->allowedFields = ["uid", "user_uid", ...$this->allowedFields, ...$fields]; $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; } final public function getTitleField(): string { return 'product_uid'; } - final public function getFields(string $action = ""): array - { - $fields = [$this->getTitleField(), "quantity", "price", "status"]; - switch ($action) { - case "index": - case "excel": - case "view": - return [$this->getTitleField(), "user_uid", "quantity", "price", "status", "updated_at", "created_at"]; - break; - default: - return $fields; - break; - } - } - final public function getFieldFilters(): array - { - return [$this->getTitleField(), "user_uid", "status"]; - } - final public function getFieldBatchFilters(): array - { - return ["status"]; - } protected function getFieldRule(string $field, array $rules, string $action = ""): array { switch ($field) { @@ -61,14 +38,13 @@ class OrderModel extends BaseModel } return $rules; } - //Field별 Form Option용 public function getFieldFormOption(string $field): array { switch ($field) { case 'product_uid': if (is_null($this->_product_options)) { - $productModel = new productModel(); + $productModel = new productModel([$this->getPrimaryKey(), 'product_uid']); $this->_product_options = $productModel->getFormOptions(); } $options = $this->_product_options; @@ -82,7 +58,6 @@ class OrderModel extends BaseModel } return $options; } - public function getEntity($conditions): OrderEntity { return $this->where($conditions)->first() ?: throw new \Exception("해당 데이터가 없습니다.\n" . var_export($conditions, true)); diff --git a/app/Models/ProductModel.php b/app/Models/ProductModel.php index 15b24cd..bb06f63 100644 --- a/app/Models/ProductModel.php +++ b/app/Models/ProductModel.php @@ -11,40 +11,17 @@ class ProductModel extends BaseModel protected $useAutoIncrement = false; protected $returnType = ProductEntity::class; protected $useSoftDeletes = true; - public function __construct() + public function __construct(array $fields = array()) { parent::__construct('Product'); - $this->allowedFields = ["uid", "user_uid", ...$this->allowedFields, ...$this->getFields(),]; + $this->allowedFields = ["uid", "user_uid", ...$this->allowedFields, ...$fields]; $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; } public function getTitleField(): string { return 'name'; } - public function getFields(string $action = ""): array - { - $fields = ["category_uid", $this->getTitleField(), "photo", "cost", "price", "sale", "stock", "view_cnt", "status", "content",]; - switch ($action) { - case "index": - case "excel": - return ["category_uid", "user_uid", $this->getTitleField(), "photo", "cost", "price", "sale", "stock", "view_cnt", "status", "created_at"]; - break; - case "view": - return [...$fields, "created_at"]; - break; - default: - return $fields; - break; - } - } - public function getFieldFilters(): array - { - return ["category_uid", "user_uid", "status"]; - } - public function getFieldBatchFilters(): array - { - return parent::getFieldBatchFilters(); - } + protected function getFieldRule(string $field, array $rules, string $action = ""): array { switch ($field) { @@ -84,7 +61,7 @@ class ProductModel extends BaseModel switch ($field) { case 'category_uid': if (is_null($this->_category_options)) { - $categoryModel = new CategoryModel(); + $categoryModel = new CategoryModel([$this->getPrimaryKey(), $this->getTitleField()]); $this->_category_options = $categoryModel->getFormOptions(); } $options = $this->_category_options; diff --git a/app/Models/UserModel.php b/app/Models/UserModel.php index 237ed71..ec065f3 100644 --- a/app/Models/UserModel.php +++ b/app/Models/UserModel.php @@ -10,40 +10,16 @@ class UserModel extends BaseModel protected $useAutoIncrement = false; protected $returnType = UserEntity::class; protected $useSoftDeletes = true; - public function __construct() + public function __construct(array $fields = array()) { parent::__construct('User'); - $this->allowedFields = ["uid", ...$this->allowedFields, ...$this->getFields()]; + $this->allowedFields = ["uid", ...$this->allowedFields, ...$fields]; $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; } public function getTitleField(): string { return 'name'; } - public function getFields(string $action = ""): array - { - $fields = ["id", "passwd", $this->getTitleField(), "email", "role", "status"]; - switch ($action) { - case "index": - case "excel": - return ["id", $this->getTitleField(), "email", "role", "status", 'created_at']; - break; - case "view": - return ["id", $this->getTitleField(), "email", "role", "status", 'updated_at', 'created_at']; - break; - default: - return $fields; - break; - } - } - public function getFieldFilters(): array - { - return ["role", "status"]; - } - public function getFieldBatchFilters(): array - { - return parent::getFieldBatchFilters(); - } protected function getFieldRule(string $field, array $rules, string $action = ""): array { switch ($field) { diff --git a/app/Models/UserSNSModel.php b/app/Models/UserSNSModel.php index b0f5e3f..13d72b0 100644 --- a/app/Models/UserSNSModel.php +++ b/app/Models/UserSNSModel.php @@ -8,40 +8,17 @@ class UserSNSModel extends BaseModel { protected $table = "tw_user_sns"; protected $returnType = UserSNSEntity::class; - public function __construct() + public function __construct($fields) { parent::__construct('UserSNS'); - $this->allowedFields = [...$this->allowedFields, ...$this->getFields(), "user_uid"]; + $this->allowedFields = [...$this->allowedFields, "user_uid", ...$fields]; $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; } public function getTitleField(): string { return 'name'; } - public function getFields(string $action = ""): array - { - $fields = ["site", "id", $this->getTitleField(), "email", "detail", "status"]; - switch ($action) { - case "index": - case "excel": - return ["user_uid", "site", "id", $this->getTitleField(), "email", "status", "created_at"]; - break; - case "view": - return [...$fields, "updated_at", "created_at"]; - break; - default: - return $fields; - break; - } - } - public function getFieldFilters(): array - { - return ["user_uid", "status"]; - } - public function getFieldBatchFilters(): array - { - return parent::getFieldBatchFilters(); - } + protected function getFieldRule(string $field, array $rules, string $action = ""): array { switch ($field) { diff --git a/app/Views/front/board/index.php b/app/Views/front/board/index.php new file mode 100644 index 0000000..1b80fde --- /dev/null +++ b/app/Views/front/board/index.php @@ -0,0 +1,34 @@ +extend('layouts/front') ?> +section('content') ?> +
+
+ "get")) ?> + + +
+ + + + + + + + getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this);"> + + + + + + + +
번호
+ +
+
+ +
+
+endSection() ?> \ No newline at end of file diff --git a/app/Views/front/board/insert.php b/app/Views/front/board/insert.php new file mode 100644 index 0000000..8295a29 --- /dev/null +++ b/app/Views/front/board/insert.php @@ -0,0 +1,21 @@ +extend('layouts/front') ?> +section('content') ?> +
+ + + + + + + + + + + +
+ + +
"btn btn-outline btn-primary")); ?>
+
+ +endSection() ?> \ No newline at end of file diff --git a/app/Views/front/board/reply.php b/app/Views/front/board/reply.php new file mode 100644 index 0000000..1d55f40 --- /dev/null +++ b/app/Views/front/board/reply.php @@ -0,0 +1,21 @@ +extend('layouts/front') ?> +section('content') ?> +
+ + + + + + + + + + + +
+ $field), $fieldFormOptions) ?> + +
"btn btn-outline btn-primary")); ?>
+
+ +endSection() ?> \ No newline at end of file diff --git a/app/Views/front/board/update.php b/app/Views/front/board/update.php new file mode 100644 index 0000000..45d1ec7 --- /dev/null +++ b/app/Views/front/board/update.php @@ -0,0 +1,21 @@ +extend('layouts/front') ?> +section('content') ?> +
+ + + + + + + + + + + +
+ $field), $fieldFormOptions) ?> + +
"btn btn-outline btn-primary")); ?>
+
+ +endSection() ?> \ No newline at end of file diff --git a/app/Views/front/board/view.php b/app/Views/front/board/view.php new file mode 100644 index 0000000..8b7bb8c --- /dev/null +++ b/app/Views/front/board/view.php @@ -0,0 +1,16 @@ +extend('layouts/front') ?> +section('content') ?> +
+ + + + + + + +
+ + +
+
+endSection() ?> \ No newline at end of file