From d4015f4e8d9cf1c1672571d21a0ed2e6802ad535 Mon Sep 17 00:00:00 2001 From: guojia <445241500@qq.com> Date: Tue, 30 Apr 2024 14:05:57 +0800 Subject: [PATCH] 1 --- app/common/model/Style.php | 15 ++++++--------- app/store/controller/Merchant.php | 5 +++-- 2 files changed, 9 insertions(+), 11 deletions(-) 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')); }