## Summary - replace the legacy Tenant and TenantMembership core models with ManagedEnvironment and ManagedEnvironmentMembership - propagate the managed environment naming and key changes across Filament resources, pages, controllers, jobs, models, and supporting runtime paths - add feature 279 spec artifacts and focused managed-environment test coverage for model behavior, route binding, panel context, authorization, and legacy guardrails ## Validation - `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/ManagedEnvironment/LegacyTenantCoreGuardTest.php tests/Feature/ManagedEnvironment/ManagedEnvironmentAuthorizationTest.php tests/Feature/ManagedEnvironment/ManagedEnvironmentPanelContextTest.php tests/Feature/ManagedEnvironment/ManagedEnvironmentRouteBindingTest.php tests/Unit/ManagedEnvironment/ManagedEnvironmentContextResolverTest.php tests/Unit/ManagedEnvironment/ManagedEnvironmentModelTest.php` - `cd apps/platform && ./vendor/bin/sail bin pint --dirty --format agent` ## Notes - branch pushed from commit `1123b122` - browser smoke test file was added but not run in this pass Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #335
63 lines
1.9 KiB
PHP
63 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Support\System;
|
|
|
|
use App\Filament\System\Pages\Directory\Tenants;
|
|
use App\Filament\System\Pages\Directory\ViewTenant;
|
|
use App\Filament\System\Pages\Directory\ViewWorkspace;
|
|
use App\Filament\System\Pages\Directory\Workspaces;
|
|
use App\Models\ManagedEnvironment;
|
|
use App\Models\Workspace;
|
|
|
|
final class SystemDirectoryLinks
|
|
{
|
|
public static function workspacesIndex(): string
|
|
{
|
|
return Workspaces::getUrl(panel: 'system');
|
|
}
|
|
|
|
public static function workspaceDetail(Workspace|int $workspace): string
|
|
{
|
|
$workspaceId = $workspace instanceof Workspace ? (int) $workspace->getKey() : (int) $workspace;
|
|
|
|
return ViewWorkspace::getUrl(['workspace' => $workspaceId], panel: 'system');
|
|
}
|
|
|
|
public static function tenantsIndex(): string
|
|
{
|
|
return Tenants::getUrl(panel: 'system');
|
|
}
|
|
|
|
public static function tenantDetail(ManagedEnvironment|string|int $tenant): string
|
|
{
|
|
$tenantRouteKey = self::tenantRouteKey($tenant);
|
|
|
|
return ViewTenant::getUrl(['tenant' => $tenantRouteKey], panel: 'system');
|
|
}
|
|
|
|
public static function adminWorkspace(Workspace|int $workspace): string
|
|
{
|
|
$workspaceId = $workspace instanceof Workspace ? (int) $workspace->getKey() : (int) $workspace;
|
|
|
|
return route('filament.admin.resources.workspaces.view', ['record' => $workspaceId]);
|
|
}
|
|
|
|
public static function adminTenant(ManagedEnvironment|string|int $tenant): string
|
|
{
|
|
$tenantRouteKey = self::tenantRouteKey($tenant);
|
|
|
|
return route('filament.admin.resources.tenants.view', ['record' => $tenantRouteKey]);
|
|
}
|
|
|
|
private static function tenantRouteKey(ManagedEnvironment|string|int $tenant): string
|
|
{
|
|
if ($tenant instanceof ManagedEnvironment) {
|
|
return (string) $tenant->getRouteKey();
|
|
}
|
|
|
|
return (string) $tenant;
|
|
}
|
|
}
|