From fc673be0c1fff5d0119d9f93058c195deca0e3e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B6=8C=ED=98=81=EC=84=B1?= Date: Thu, 19 Mar 2026 23:58:02 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20[pricing]=20=EB=8B=A8=EA=B0=80=20?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D/=EC=83=81=EC=84=B8=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=ED=92=88=EB=AA=A9=EC=BD=94=EB=93=9C=C2=B7=ED=92=88=EB=AA=A9?= =?UTF-8?q?=EB=AA=85=20=EB=AF=B8=ED=91=9C=EC=8B=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Price 모델에 item() BelongsTo 관계 추가 - index/show에서 item:id,code,name,item_category eager load --- app/Models/Products/Price.php | 8 ++++++++ app/Services/PricingService.php | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/Models/Products/Price.php b/app/Models/Products/Price.php index 13ef9f46..0dea57a7 100644 --- a/app/Models/Products/Price.php +++ b/app/Models/Products/Price.php @@ -81,6 +81,14 @@ class Price extends Model // Relations // ───────────────────────────────────────────────────────────── + /** + * 품목 관계 + */ + public function item(): BelongsTo + { + return $this->belongsTo(\App\Models\Items\Item::class, 'item_id'); + } + /** * 고객 그룹 관계 */ diff --git a/app/Services/PricingService.php b/app/Services/PricingService.php index 914d7052..32191c41 100644 --- a/app/Services/PricingService.php +++ b/app/Services/PricingService.php @@ -30,7 +30,7 @@ public function index(array $params): LengthAwarePaginator $validAt = $params['valid_at'] ?? null; $query = Price::query() - ->with(['clientGroup:id,name']) + ->with(['clientGroup:id,name', 'item:id,code,name,item_category']) ->where('tenant_id', $tenantId); // 검색어 필터 @@ -81,7 +81,7 @@ public function show(int $id): Price $tenantId = $this->tenantId(); $price = Price::query() - ->with(['clientGroup:id,name', 'revisions' => function ($q) { + ->with(['clientGroup:id,name', 'item:id,code,name,item_category', 'revisions' => function ($q) { $q->orderByDesc('revision_number')->limit(10); }]) ->where('tenant_id', $tenantId)