Fix diagnostic button visibility for admin users

Replace isAdmin() (Spatie-dependent) with direct role check and add
TenantManager fallback using hostname subdomain so the button appears
even if TenantManager was not resolved for the current request.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-09-06 11:22:53 +00:00
parent 0efe2e0bff
commit 8e32444a13
@@ -18,11 +18,13 @@ class ListWorkOrders extends ListRecords
$actions = [Actions\CreateAction::make()];
$user = auth()->user();
if (! $user?->isAdmin()) {
if (! in_array($user?->role, ['admin', 'owner'])) {
return $actions;
}
$tenantId = app(TenantManager::class)->currentId();
$tenantId = app(TenantManager::class)->currentId()
?? DB::table('companies')->where('slug', request()->getHost() === 'localhost' ? 'psauto' : explode('.', request()->getHost())[0])->value('id');
if (! $tenantId) {
return $actions;
}