## Summary - move the Laravel application into `apps/platform` and keep the repository root for orchestration, docs, and tooling - update the local command model, Sail/Docker wiring, runtime paths, and ignore rules around the new platform location - add relocation quickstart/contracts plus focused smoke coverage for bootstrap, command model, routes, and runtime behavior ## Validation - `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/PlatformRelocation` - integrated browser smoke validated `/up`, `/`, `/admin`, `/admin/choose-workspace`, and tenant route semantics for `200`, `403`, and `404` ## Remaining Rollout Checks - validate Dokploy build context and working-directory assumptions against the new `apps/platform` layout - confirm web, queue, and scheduler processes all start from the expected working directory in staging/production - verify no legacy volume mounts or asset-publish paths still point at the old root-level `public/` or `storage/` locations Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #213
82 lines
1.9 KiB
PHP
82 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Services\Runbooks;
|
|
|
|
use Illuminate\Validation\ValidationException;
|
|
|
|
final readonly class FindingsLifecycleBackfillScope
|
|
{
|
|
public const string MODE_ALL_TENANTS = 'all_tenants';
|
|
|
|
public const string MODE_SINGLE_TENANT = 'single_tenant';
|
|
|
|
private function __construct(
|
|
public string $mode,
|
|
public ?int $tenantId,
|
|
) {}
|
|
|
|
public static function allTenants(): self
|
|
{
|
|
return new self(
|
|
mode: self::MODE_ALL_TENANTS,
|
|
tenantId: null,
|
|
);
|
|
}
|
|
|
|
public static function singleTenant(int $tenantId): self
|
|
{
|
|
$tenantId = (int) $tenantId;
|
|
|
|
if ($tenantId <= 0) {
|
|
throw ValidationException::withMessages([
|
|
'scope.tenant_id' => 'Select a valid tenant.',
|
|
]);
|
|
}
|
|
|
|
return new self(
|
|
mode: self::MODE_SINGLE_TENANT,
|
|
tenantId: $tenantId,
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @param array<string, mixed> $data
|
|
*/
|
|
public static function fromArray(array $data): self
|
|
{
|
|
$mode = trim((string) ($data['mode'] ?? ''));
|
|
|
|
if ($mode === '' || $mode === self::MODE_ALL_TENANTS) {
|
|
return self::allTenants();
|
|
}
|
|
|
|
if ($mode !== self::MODE_SINGLE_TENANT) {
|
|
throw ValidationException::withMessages([
|
|
'scope.mode' => 'Select a valid scope mode.',
|
|
]);
|
|
}
|
|
|
|
$tenantId = $data['tenant_id'] ?? null;
|
|
|
|
if (! is_numeric($tenantId)) {
|
|
throw ValidationException::withMessages([
|
|
'scope.tenant_id' => 'Select a tenant.',
|
|
]);
|
|
}
|
|
|
|
return self::singleTenant((int) $tenantId);
|
|
}
|
|
|
|
public function isAllTenants(): bool
|
|
{
|
|
return $this->mode === self::MODE_ALL_TENANTS;
|
|
}
|
|
|
|
public function isSingleTenant(): bool
|
|
{
|
|
return $this->mode === self::MODE_SINGLE_TENANT;
|
|
}
|
|
}
|