diff --git a/app/common/model/Style.php b/app/common/model/Style.php index 2dc5a29d..ba29c312 100644 --- a/app/common/model/Style.php +++ b/app/common/model/Style.php @@ -34,16 +34,13 @@ class Style extends BaseModel * @param int $storeId * @return static|array|null */ - public static function detail() + public static function detail(int $styleId) { - try { - $list = self::withoutGlobalScope() - ->where('1', '=', 1) - ->find(); - return $list ?? null; - } catch (\Exception $e) { - return null; - } + $where = [ + 'style_id' => $styleId, + 'store_id' => self::$storeId + ]; + return static::get($where, []); } /** diff --git a/app/store/controller/Merchant.php b/app/store/controller/Merchant.php index 939648a8..9b40f56e 100644 --- a/app/store/controller/Merchant.php +++ b/app/store/controller/Merchant.php @@ -134,7 +134,8 @@ class Merchant extends Controller // 新增记录 $model = new StyleModel; $data = $this->postForm(); - if ($model->add($data)) { + $data['style_id'] = 1; + if ($model->edit($data)) { return $this->renderSuccess('添加成功'); } return $this->renderError($model->getError() ?: '添加失败'); @@ -143,7 +144,7 @@ class Merchant extends Controller public function getPageStyle(): Json { // 新增记录 - $detail = StyleModel::detail(); + $detail = StyleModel::detail(1); return $this->renderSuccess(compact('detail')); }