From 9eaed75c40eaaea605faedbd86f6a263ac17c393 Mon Sep 17 00:00:00 2001 From: Kilian Trunk Date: Mon, 13 Oct 2025 10:55:42 +0200 Subject: [PATCH] feat: add cached ability checks concern --- .../Concerns/HasCachedAbilityChecks.php | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/Filament/Concerns/HasCachedAbilityChecks.php diff --git a/src/Filament/Concerns/HasCachedAbilityChecks.php b/src/Filament/Concerns/HasCachedAbilityChecks.php new file mode 100644 index 0000000..bd21c07 --- /dev/null +++ b/src/Filament/Concerns/HasCachedAbilityChecks.php @@ -0,0 +1,24 @@ +attributes->has($key)) { + $request->attributes->set($key, auth()->user()?->can($ability) ?? false); + } + + return (bool) $request->attributes->get($key); + } + + return auth()->user()?->can($ability) ?? false; + } +}