TenantAtlas/apps/platform/app/Support/Ui/EnterpriseDetail/EnterpriseDetailBuilder.php
ahmido ce0615a9c1 Spec 182: relocate Laravel platform to apps/platform (#213)
## 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
2026-04-08 08:40:47 +00:00

136 lines
3.4 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Support\Ui\EnterpriseDetail;
use LogicException;
final class EnterpriseDetailBuilder
{
private ?SummaryHeaderData $header = null;
/**
* @var array<string, mixed>|null
*/
private ?array $decisionZone = null;
/**
* @var list<DetailSectionData>
*/
private array $mainSections = [];
/**
* @var list<SupportingCardData>
*/
private array $supportingGroups = [];
/**
* @var list<TechnicalDetailData>
*/
private array $technicalSections = [];
/**
* @var list<array{title: string, description?: ?string, icon?: ?string}>
*/
private array $emptyStateNotes = [];
public function __construct(
private readonly string $resourceType,
private readonly string $scope,
) {}
public static function make(string $resourceType, string $scope): self
{
return new self($resourceType, $scope);
}
public function header(SummaryHeaderData $header): self
{
$this->header = $header;
return $this;
}
/**
* @param array<string, mixed> $decisionZone
*/
public function decisionZone(array $decisionZone): self
{
$this->decisionZone = $decisionZone;
return $this;
}
public function addSection(DetailSectionData ...$sections): self
{
foreach ($sections as $section) {
$this->mainSections[] = $section;
}
return $this;
}
public function addSupportingCard(SupportingCardData ...$cards): self
{
return $this->addSupportingGroup(...$cards);
}
public function addSupportingGroup(SupportingCardData ...$groups): self
{
foreach ($groups as $group) {
$this->supportingGroups[] = $group;
}
return $this;
}
public function addTechnicalSection(TechnicalDetailData ...$sections): self
{
foreach ($sections as $section) {
$this->technicalSections[] = $section;
}
return $this;
}
/**
* @param list<array{title: string, description?: ?string, icon?: ?string}> $notes
*/
public function emptyStateNotes(array $notes): self
{
$this->emptyStateNotes = $notes;
return $this;
}
public function build(): EnterpriseDetailPageData
{
if (! $this->header instanceof SummaryHeaderData) {
throw new LogicException('Enterprise detail pages require a summary header.');
}
return new EnterpriseDetailPageData(
resourceType: $this->resourceType,
scope: $this->scope,
header: $this->header,
decisionZone: is_array($this->decisionZone) && $this->decisionZone !== []
? $this->decisionZone
: null,
mainSections: array_values(array_filter(
$this->mainSections,
static fn (DetailSectionData $section): bool => $section->shouldRender(),
)),
supportingGroups: array_values(array_filter(
$this->supportingGroups,
static fn (SupportingCardData $group): bool => $group->shouldRender(),
)),
technicalSections: array_values(array_filter(
$this->technicalSections,
static fn (TechnicalDetailData $section): bool => $section->shouldRender(),
)),
emptyStateNotes: $this->emptyStateNotes,
);
}
}