From 577329365ae371f34d2f9b6151ba7a34ad2bf235 Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Thu, 6 Aug 2026 09:57:01 +0700 Subject: [PATCH] feat: add active and nonactive scopes to RawMaterial model and apply active scope in CuttingService --- app/Models/RawMaterial.php | 12 ++++++++++++ app/Services/Admin/Manage/CuttingService.php | 1 + 2 files changed, 13 insertions(+) diff --git a/app/Models/RawMaterial.php b/app/Models/RawMaterial.php index 299d748..793b471 100644 --- a/app/Models/RawMaterial.php +++ b/app/Models/RawMaterial.php @@ -41,6 +41,18 @@ protected function unitLabel(): Attribute ); } + #[Scope] + protected function active(Builder $query): void + { + $query->where('is_active', true); + } + + #[Scope] + protected function nonactive(Builder $query): void + { + $query->where('is_active', false); + } + #[Scope] protected function kg(Builder $query): void { diff --git a/app/Services/Admin/Manage/CuttingService.php b/app/Services/Admin/Manage/CuttingService.php index 988ba18..36efe5c 100644 --- a/app/Services/Admin/Manage/CuttingService.php +++ b/app/Services/Admin/Manage/CuttingService.php @@ -69,6 +69,7 @@ public function getForCreate(): array ->with([ 'rawMaterialPrices:id,raw_material_id,variant,price,stock', ]) + ->active() ->orderBy('name') ->get() ->each(function (RawMaterial $rawMaterial) {