From 3bcdeea800202437679d708a15823fc2aedafe4f Mon Sep 17 00:00:00 2001 From: MartinOscar <40749467+rmartinoscar@users.noreply.github.com> Date: Sun, 26 Oct 2025 16:24:34 +0100 Subject: [PATCH] Leverage `user()` helper (#1832) --- app/Filament/Admin/Resources/Users/UserResource.php | 2 +- app/Filament/Server/Pages/Startup.php | 2 +- app/Models/ActivityLog.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Filament/Admin/Resources/Users/UserResource.php b/app/Filament/Admin/Resources/Users/UserResource.php index 052924d66..58b7b5ef6 100644 --- a/app/Filament/Admin/Resources/Users/UserResource.php +++ b/app/Filament/Admin/Resources/Users/UserResource.php @@ -414,7 +414,7 @@ class UserResource extends Resource $sshKey->delete(); Activity::event('user:ssh-key.delete') - ->actor(auth()->user()) + ->actor(user()) ->subject($user) ->subject($sshKey) ->property('fingerprint', $sshKey->fingerprint) diff --git a/app/Filament/Server/Pages/Startup.php b/app/Filament/Server/Pages/Startup.php index 386df191c..231875172 100644 --- a/app/Filament/Server/Pages/Startup.php +++ b/app/Filament/Server/Pages/Startup.php @@ -51,7 +51,7 @@ class Startup extends ServerFormPage ->label(trans('server/startup.command')) ->live() ->visible(fn (Server $server) => in_array($server->startup, $server->egg->startup_commands)) - ->disabled(fn (Server $server) => !auth()->user()->can(Permission::ACTION_STARTUP_UPDATE, $server)) + ->disabled(fn (Server $server) => !user()?->can(Permission::ACTION_STARTUP_UPDATE, $server)) ->formatStateUsing(fn (Server $server) => $server->startup) ->afterStateUpdated(function ($state, Server $server, Set $set) { $original = $server->startup; diff --git a/app/Models/ActivityLog.php b/app/Models/ActivityLog.php index d0fe61169..3b44a8e5a 100644 --- a/app/Models/ActivityLog.php +++ b/app/Models/ActivityLog.php @@ -165,7 +165,7 @@ class ActivityLog extends Model implements HasIcon, HasLabel public function getIp(): ?string { - return auth()->user()->can('seeIps activityLog') ? $this->ip : null; + return user()?->can('seeIps activityLog') ? $this->ip : null; } public function htmlable(): string