TenantAtlas/app/Support/Tenants/TenantPageCategory.php
ahmido 641bb4afde feat: implement tenant lifecycle operability semantics (#172)
## Summary
- implement Spec 143 tenant lifecycle, operability, and tenant-context semantics across chooser, tenant management, onboarding, and canonical operation viewers
- add centralized tenant lifecycle and operability support types, audit action coverage, and lifecycle-aware badge and action handling
- add feature and unit coverage for tenant chooser eligibility, global search scoping, canonical operation access, onboarding authorization, and lifecycle presentation

## Testing
- vendor/bin/sail artisan test --compact
- vendor/bin/sail bin pint --dirty --format agent

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #172
2026-03-15 09:08:36 +00:00

47 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Support\Tenants;
use Illuminate\Http\Request;
enum TenantPageCategory: string
{
case WorkspaceScoped = 'workspace_scoped';
case TenantBound = 'tenant_bound';
case OnboardingWorkflow = 'onboarding_workflow';
case CanonicalWorkspaceRecordViewer = 'canonical_workspace_record_viewer';
public static function fromRequest(?Request $request = null): self
{
if (! $request instanceof Request) {
return self::WorkspaceScoped;
}
return self::fromPath('/'.ltrim($request->path(), '/'));
}
public static function fromPath(string $path): self
{
$normalizedPath = '/'.ltrim($path, '/');
if (preg_match('#^/admin/operations/[^/]+$#', $normalizedPath) === 1) {
return self::CanonicalWorkspaceRecordViewer;
}
if (preg_match('#^/admin/onboarding(?:/[^/]+)?$#', $normalizedPath) === 1) {
return self::OnboardingWorkflow;
}
if (
preg_match('#^/admin/t/[^/]+(?:/|$)#', $normalizedPath) === 1
|| preg_match('#^/admin/tenants/[^/]+(?:/|$)#', $normalizedPath) === 1
) {
return self::TenantBound;
}
return self::WorkspaceScoped;
}
}