feat: clear cache for assignable roles and permissions in various services to ensure data consistency
This commit is contained in:
parent
ef90f8361f
commit
ba01039b41
@ -128,6 +128,7 @@ function () use ($validated): User {
|
|||||||
'Gagal membuat karyawan',
|
'Gagal membuat karyawan',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->cacheForget('system:assignable_roles');
|
||||||
$this->cacheForgetByPattern('hr:employees:*');
|
$this->cacheForgetByPattern('hr:employees:*');
|
||||||
|
|
||||||
$this->notifyOwner(
|
$this->notifyOwner(
|
||||||
@ -189,6 +190,7 @@ function () use ($validated, $user, $employee): void {
|
|||||||
'Gagal memperbarui karyawan',
|
'Gagal memperbarui karyawan',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->cacheForget('system:assignable_roles');
|
||||||
$this->cacheForgetByPattern('hr:employees:*');
|
$this->cacheForgetByPattern('hr:employees:*');
|
||||||
|
|
||||||
$this->notifyOwner(
|
$this->notifyOwner(
|
||||||
@ -213,6 +215,7 @@ function () use ($user, $validated): void {
|
|||||||
'Gagal memperbarui status karyawan',
|
'Gagal memperbarui status karyawan',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->cacheForget('system:assignable_roles');
|
||||||
$this->cacheForgetByPattern('hr:employees:*');
|
$this->cacheForgetByPattern('hr:employees:*');
|
||||||
|
|
||||||
$statusLabel = $validated['is_active'] ? 'aktif' : 'nonaktif';
|
$statusLabel = $validated['is_active'] ? 'aktif' : 'nonaktif';
|
||||||
@ -237,6 +240,7 @@ function () use ($user): void {
|
|||||||
'Gagal mereset kata sandi karyawan',
|
'Gagal mereset kata sandi karyawan',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->cacheForget('system:assignable_roles');
|
||||||
$this->cacheForgetByPattern('hr:employees:*');
|
$this->cacheForgetByPattern('hr:employees:*');
|
||||||
|
|
||||||
$this->notifyOwner(
|
$this->notifyOwner(
|
||||||
@ -259,6 +263,7 @@ function () use ($user): void {
|
|||||||
'Gagal menghapus karyawan',
|
'Gagal menghapus karyawan',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->cacheForget('system:assignable_roles');
|
||||||
$this->cacheForgetByPattern('hr:employees:*');
|
$this->cacheForgetByPattern('hr:employees:*');
|
||||||
|
|
||||||
$this->notifyOwner(
|
$this->notifyOwner(
|
||||||
|
|||||||
@ -156,9 +156,7 @@ public function submitVerification(
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->cacheForgetByPattern('manage:stocks:*');
|
$this->cacheForgetByPattern('manage:stocks:*');
|
||||||
if ($isOwner) {
|
$this->cacheForgetByPattern('prices:*');
|
||||||
$this->cacheForgetByPattern('prices:*');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function approveVerification(
|
public function approveVerification(
|
||||||
|
|||||||
@ -254,6 +254,7 @@ function () use ($validated, $product, $user, $isOwner): void {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$this->cacheForgetByPattern('master:products:*');
|
$this->cacheForgetByPattern('master:products:*');
|
||||||
|
$this->cacheForgetByPattern('prices:*');
|
||||||
$this->cacheForget('homepage:page_data');
|
$this->cacheForget('homepage:page_data');
|
||||||
|
|
||||||
if ($isOwner) {
|
if ($isOwner) {
|
||||||
@ -328,6 +329,7 @@ public function delete(Product $product, User $user): void
|
|||||||
$name = $product->name;
|
$name = $product->name;
|
||||||
$this->applyDeleteSubject($product);
|
$this->applyDeleteSubject($product);
|
||||||
$this->cacheForgetByPattern('master:products:*');
|
$this->cacheForgetByPattern('master:products:*');
|
||||||
|
$this->cacheForgetByPattern('prices:*');
|
||||||
$this->cacheForget('homepage:page_data');
|
$this->cacheForget('homepage:page_data');
|
||||||
|
|
||||||
$this->notifyOwner(
|
$this->notifyOwner(
|
||||||
@ -435,6 +437,7 @@ public function applyVerificationRequest(OwnerVerificationRequest $verificationR
|
|||||||
};
|
};
|
||||||
|
|
||||||
$this->cacheForgetByPattern('master:products:*');
|
$this->cacheForgetByPattern('master:products:*');
|
||||||
|
$this->cacheForgetByPattern('prices:*');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rejectVerificationRequest(OwnerVerificationRequest $verificationRequest): void
|
public function rejectVerificationRequest(OwnerVerificationRequest $verificationRequest): void
|
||||||
@ -449,6 +452,7 @@ public function rejectVerificationRequest(OwnerVerificationRequest $verification
|
|||||||
};
|
};
|
||||||
|
|
||||||
$this->cacheForgetByPattern('master:products:*');
|
$this->cacheForgetByPattern('master:products:*');
|
||||||
|
$this->cacheForgetByPattern('prices:*');
|
||||||
$this->cacheForget('homepage:page_data');
|
$this->cacheForget('homepage:page_data');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -46,14 +46,14 @@ public function paginateForIndex(array $tableQuery, string $isActive, string $st
|
|||||||
$q->whereHas('rawMaterial', fn ($q) => $q->where('unit', RawMaterialUnit::YARD->value))
|
$q->whereHas('rawMaterial', fn ($q) => $q->where('unit', RawMaterialUnit::YARD->value))
|
||||||
->where('stock', '<', 20);
|
->where('stock', '<', 20);
|
||||||
})
|
})
|
||||||
->orWhere(function ($q): void {
|
->orWhere(function ($q): void {
|
||||||
$q->whereHas('rawMaterial', fn ($q) => $q->where('unit', RawMaterialUnit::METER->value))
|
$q->whereHas('rawMaterial', fn ($q) => $q->where('unit', RawMaterialUnit::METER->value))
|
||||||
->where('stock', '<', 10);
|
->where('stock', '<', 10);
|
||||||
})
|
})
|
||||||
->orWhere(function ($q): void {
|
->orWhere(function ($q): void {
|
||||||
$q->whereHas('rawMaterial', fn ($q) => $q->where('unit', RawMaterialUnit::KILOGRAM->value))
|
$q->whereHas('rawMaterial', fn ($q) => $q->where('unit', RawMaterialUnit::KILOGRAM->value))
|
||||||
->where('stock', '<', 5);
|
->where('stock', '<', 5);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
|
|||||||
@ -87,6 +87,8 @@ public function create(array $validated): void
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->cacheForget('system:permissions');
|
||||||
|
$this->cacheForget('system:assignable_roles');
|
||||||
$this->cacheForgetByPattern('system: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:*');
|
$this->cacheForgetByPattern('system:roles:*');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,6 +125,8 @@ public function delete(Role $role): void
|
|||||||
{
|
{
|
||||||
$role->delete();
|
$role->delete();
|
||||||
|
|
||||||
|
$this->cacheForget('system:permissions');
|
||||||
|
$this->cacheForget('system:assignable_roles');
|
||||||
$this->cacheForgetByPattern('system:roles:*');
|
$this->cacheForgetByPattern('system:roles:*');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user