From 438003707f4b130b9a0cdd0dd72218cbf4754e71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Tue, 14 May 2024 10:06:41 +0900 Subject: [PATCH] vhost init...2 --- app/Models/BaseModel.php | 8 +++----- app/Models/BillingModel.php | 2 +- app/Models/BoardModel.php | 3 +-- app/Models/CategoryModel.php | 2 +- app/Models/OrderBillingModel.php | 2 +- app/Models/OrderModel.php | 2 +- app/Models/ProductModel.php | 2 +- app/Models/SitepageModel.php | 3 +-- app/Models/UserModel.php | 3 +-- app/Models/UserSNSModel.php | 3 +-- 10 files changed, 12 insertions(+), 18 deletions(-) diff --git a/app/Models/BaseModel.php b/app/Models/BaseModel.php index a57b3be..d5afed6 100644 --- a/app/Models/BaseModel.php +++ b/app/Models/BaseModel.php @@ -60,6 +60,9 @@ abstract class BaseModel extends Model $this->_session = \Config\Services::session(); $this->_validation = \Config\Services::validation(); } + abstract public function getTitleField(): string; + abstract public function getEntity($conditions): BaseEntity; + final protected function getClassName() { return $this->_className; @@ -78,15 +81,10 @@ abstract class BaseModel extends Model } return $this->_categoryModel; } - abstract public function getTitleField(): string; final public function getPrimaryKey() { return $this->primaryKey; } - public function getEntity($conditions): BaseEntity - { - return $this->where($conditions)->first() ?: throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 해당 데이터가 없습니다."); - } public function getEntitys(array $conditions = array()): array { return $this->where($conditions)->findAll(); diff --git a/app/Models/BillingModel.php b/app/Models/BillingModel.php index 5f0421e..f5005fc 100644 --- a/app/Models/BillingModel.php +++ b/app/Models/BillingModel.php @@ -65,7 +65,7 @@ class BillingModel extends BaseModel } public function getEntity($conditions): BillingEntity { - return parent::getEntity($conditions); + return $this->where($conditions)->first() ?: throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 해당 데이터가 없습니다."); } public function create(array $formDatas): BillingEntity { diff --git a/app/Models/BoardModel.php b/app/Models/BoardModel.php index bf6a88f..fa34bbf 100644 --- a/app/Models/BoardModel.php +++ b/app/Models/BoardModel.php @@ -54,9 +54,8 @@ class BoardModel extends BaseHierarchyModel } public function getEntity($conditions): BoardEntity { - return $this->where($conditions)->first() ?: throw new \Exception("해당 데이터가 없습니다.\n" . var_export($conditions, true)); + return $this->where($conditions)->first() ?: throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 해당 데이터가 없습니다."); } - public function create(array $formDatas): BoardEntity { return $this->create_process(new BoardEntity(), $formDatas); diff --git a/app/Models/CategoryModel.php b/app/Models/CategoryModel.php index c0e69fb..acbd814 100644 --- a/app/Models/CategoryModel.php +++ b/app/Models/CategoryModel.php @@ -117,7 +117,7 @@ class CategoryModel extends BaseHierarchyModel public function getEntity($conditions): CategoryEntity { - return new CategoryEntity(parent::getEntity($conditions)->toArray()); + return $this->where($conditions)->first() ?: throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 해당 데이터가 없습니다."); } public function getEntitys(array $conditions = array()): array { diff --git a/app/Models/OrderBillingModel.php b/app/Models/OrderBillingModel.php index 089de51..a9a982e 100644 --- a/app/Models/OrderBillingModel.php +++ b/app/Models/OrderBillingModel.php @@ -37,7 +37,7 @@ class OrderBillingModel extends BaseModel } public function getEntity($conditions): OrderBillingEntity { - return parent::getEntity($conditions); + return $this->where($conditions)->first() ?: throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 해당 데이터가 없습니다."); } public function create(array $formDatas): OrderBillingEntity { diff --git a/app/Models/OrderModel.php b/app/Models/OrderModel.php index 5bbec4d..2dafcbd 100644 --- a/app/Models/OrderModel.php +++ b/app/Models/OrderModel.php @@ -74,7 +74,7 @@ class OrderModel extends BaseModel } public function getEntity($conditions): OrderEntity { - return parent::getEntity($conditions); + return $this->where($conditions)->first() ?: throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 해당 데이터가 없습니다."); } public function create(array $formDatas): OrderEntity { diff --git a/app/Models/ProductModel.php b/app/Models/ProductModel.php index 295ccc1..ce7258e 100644 --- a/app/Models/ProductModel.php +++ b/app/Models/ProductModel.php @@ -65,7 +65,7 @@ class ProductModel extends BaseModel public function getEntity($conditions): ProductEntity { - return parent::getEntity($conditions); + return $this->where($conditions)->first() ?: throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 해당 데이터가 없습니다."); } public function create(array $formDatas): ProductEntity { diff --git a/app/Models/SitepageModel.php b/app/Models/SitepageModel.php index f6a3536..d531ff4 100644 --- a/app/Models/SitepageModel.php +++ b/app/Models/SitepageModel.php @@ -49,9 +49,8 @@ class SitepageModel extends BaseModel public function getEntity($conditions): SitepageEntity { - return $this->where($conditions)->first() ?: throw new \Exception("해당 데이터가 없습니다.\n" . var_export($conditions, true)); + return $this->where($conditions)->first() ?: throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 해당 데이터가 없습니다."); } - public function create(array $formDatas): SitepageEntity { return $this->create_process(new SitepageEntity(), $formDatas); diff --git a/app/Models/UserModel.php b/app/Models/UserModel.php index fc01aee..9ff8250 100644 --- a/app/Models/UserModel.php +++ b/app/Models/UserModel.php @@ -57,9 +57,8 @@ class UserModel extends BaseModel } public function getEntity($conditions): UserEntity { - return parent::getEntity($conditions); + return $this->where($conditions)->first() ?: throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 해당 데이터가 없습니다."); } - protected function changeFormData(string $action, string $field, array $formDatas, $entity) { switch ($field) { diff --git a/app/Models/UserSNSModel.php b/app/Models/UserSNSModel.php index 3a3ca16..0f68c50 100644 --- a/app/Models/UserSNSModel.php +++ b/app/Models/UserSNSModel.php @@ -49,9 +49,8 @@ class UserSNSModel extends BaseModel } public function getEntity($conditions): UserSNSEntity { - return parent::getEntity($conditions); + return $this->where($conditions)->first() ?: throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 해당 데이터가 없습니다."); } - public function create(array $formDatas): UserSNSEntity { return $this->create_process(new UserSNSEntity(), $formDatas);