diff --git a/app/Services/Hr/EmployeeService.php b/app/Services/Hr/EmployeeService.php index 316c4c2..1160ae5 100644 --- a/app/Services/Hr/EmployeeService.php +++ b/app/Services/Hr/EmployeeService.php @@ -128,6 +128,7 @@ function () use ($validated): User { 'Gagal membuat karyawan', ); + $this->cacheForget('system:assignable_roles'); $this->cacheForgetByPattern('hr:employees:*'); $this->notifyOwner( @@ -189,6 +190,7 @@ function () use ($validated, $user, $employee): void { 'Gagal memperbarui karyawan', ); + $this->cacheForget('system:assignable_roles'); $this->cacheForgetByPattern('hr:employees:*'); $this->notifyOwner( @@ -213,6 +215,7 @@ function () use ($user, $validated): void { 'Gagal memperbarui status karyawan', ); + $this->cacheForget('system:assignable_roles'); $this->cacheForgetByPattern('hr:employees:*'); $statusLabel = $validated['is_active'] ? 'aktif' : 'nonaktif'; @@ -237,6 +240,7 @@ function () use ($user): void { 'Gagal mereset kata sandi karyawan', ); + $this->cacheForget('system:assignable_roles'); $this->cacheForgetByPattern('hr:employees:*'); $this->notifyOwner( @@ -259,6 +263,7 @@ function () use ($user): void { 'Gagal menghapus karyawan', ); + $this->cacheForget('system:assignable_roles'); $this->cacheForgetByPattern('hr:employees:*'); $this->notifyOwner( diff --git a/app/Services/Manage/StockService.php b/app/Services/Manage/StockService.php index 8849634..ab7b2c5 100644 --- a/app/Services/Manage/StockService.php +++ b/app/Services/Manage/StockService.php @@ -156,9 +156,7 @@ public function submitVerification( } $this->cacheForgetByPattern('manage:stocks:*'); - if ($isOwner) { - $this->cacheForgetByPattern('prices:*'); - } + $this->cacheForgetByPattern('prices:*'); } public function approveVerification( diff --git a/app/Services/Master/ProductService.php b/app/Services/Master/ProductService.php index b413e8d..206cf79 100644 --- a/app/Services/Master/ProductService.php +++ b/app/Services/Master/ProductService.php @@ -254,6 +254,7 @@ function () use ($validated, $product, $user, $isOwner): void { ); $this->cacheForgetByPattern('master:products:*'); + $this->cacheForgetByPattern('prices:*'); $this->cacheForget('homepage:page_data'); if ($isOwner) { @@ -328,6 +329,7 @@ public function delete(Product $product, User $user): void $name = $product->name; $this->applyDeleteSubject($product); $this->cacheForgetByPattern('master:products:*'); + $this->cacheForgetByPattern('prices:*'); $this->cacheForget('homepage:page_data'); $this->notifyOwner( @@ -435,6 +437,7 @@ public function applyVerificationRequest(OwnerVerificationRequest $verificationR }; $this->cacheForgetByPattern('master:products:*'); + $this->cacheForgetByPattern('prices:*'); } public function rejectVerificationRequest(OwnerVerificationRequest $verificationRequest): void @@ -449,6 +452,7 @@ public function rejectVerificationRequest(OwnerVerificationRequest $verification }; $this->cacheForgetByPattern('master:products:*'); + $this->cacheForgetByPattern('prices:*'); $this->cacheForget('homepage:page_data'); } diff --git a/app/Services/Master/RawMaterialService.php b/app/Services/Master/RawMaterialService.php index 1726df1..85dbbd4 100644 --- a/app/Services/Master/RawMaterialService.php +++ b/app/Services/Master/RawMaterialService.php @@ -46,14 +46,14 @@ public function paginateForIndex(array $tableQuery, string $isActive, string $st $q->whereHas('rawMaterial', fn ($q) => $q->where('unit', RawMaterialUnit::YARD->value)) ->where('stock', '<', 20); }) - ->orWhere(function ($q): void { - $q->whereHas('rawMaterial', fn ($q) => $q->where('unit', RawMaterialUnit::METER->value)) - ->where('stock', '<', 10); - }) - ->orWhere(function ($q): void { - $q->whereHas('rawMaterial', fn ($q) => $q->where('unit', RawMaterialUnit::KILOGRAM->value)) - ->where('stock', '<', 5); - }); + ->orWhere(function ($q): void { + $q->whereHas('rawMaterial', fn ($q) => $q->where('unit', RawMaterialUnit::METER->value)) + ->where('stock', '<', 10); + }) + ->orWhere(function ($q): void { + $q->whereHas('rawMaterial', fn ($q) => $q->where('unit', RawMaterialUnit::KILOGRAM->value)) + ->where('stock', '<', 5); + }); }); }), ]) diff --git a/app/Services/System/RoleService.php b/app/Services/System/RoleService.php index 776bef8..1ff4872 100644 --- a/app/Services/System/RoleService.php +++ b/app/Services/System/RoleService.php @@ -87,6 +87,8 @@ public function create(array $validated): void ]); } + $this->cacheForget('system:permissions'); + $this->cacheForget('system:assignable_roles'); $this->cacheForgetByPattern('system:roles:*'); } @@ -114,6 +116,8 @@ public function update(Role $role, array $validated): void ]); } + $this->cacheForget('system:permissions'); + $this->cacheForget('system:assignable_roles'); $this->cacheForgetByPattern('system:roles:*'); } @@ -121,6 +125,8 @@ public function delete(Role $role): void { $role->delete(); + $this->cacheForget('system:permissions'); + $this->cacheForget('system:assignable_roles'); $this->cacheForgetByPattern('system:roles:*'); }