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:
@@ -18,11 +18,13 @@ class ListWorkOrders extends ListRecords
|
|||||||
$actions = [Actions\CreateAction::make()];
|
$actions = [Actions\CreateAction::make()];
|
||||||
|
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
if (! $user?->isAdmin()) {
|
if (! in_array($user?->role, ['admin', 'owner'])) {
|
||||||
return $actions;
|
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) {
|
if (! $tenantId) {
|
||||||
return $actions;
|
return $actions;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user