From 2d59a6f9da9788bf34be9ae9d5defc604e5c7299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Tue, 2 Aug 2022 20:15:57 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20#20220802=20=E8=A7=84=E6=A0=BC=E5=95=86?= =?UTF-8?q?=E5=93=81=E6=9F=A5=E7=9C=8B=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Goods/GoodsSkusController.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Goods/GoodsSkusController.php b/app/Http/Controllers/Goods/GoodsSkusController.php index cf40820..ff4a3fa 100644 --- a/app/Http/Controllers/Goods/GoodsSkusController.php +++ b/app/Http/Controllers/Goods/GoodsSkusController.php @@ -32,7 +32,11 @@ class GoodsSkusController extends Controller public function show($id) { - return new GoodsSkuResource(GoodsSku::query()->with(['goods', 'brand'])->find($id)); + return new GoodsSkuResource(GoodsSku::query() + ->with(['goods' => function ($query) { + $query->with(['type:id,name', 'brand:id,name']); + }]) + ->find($id)); } public function update($id, Request $request) @@ -41,7 +45,7 @@ class GoodsSkusController extends Controller $this->validateUpdate($data); $sku = GoodsSku::query()->find($id); $this->setBeforeUpdate($sku->toArray()); - $sku->save($data); + $sku->update($data); $this->setAfterUpdate($sku->toArray()); $this->addLog($id, 'update');