TenantAtlas/app/Support/Ui/EnterpriseDetail/PageActionData.php
2026-03-11 00:05:33 +01:00

56 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Support\Ui\EnterpriseDetail;
final readonly class PageActionData
{
public function __construct(
public string $label,
public string $placement = 'header',
public ?string $url = null,
public ?string $actionName = null,
public bool $destructive = false,
public bool $requiresConfirmation = false,
public bool $visible = true,
public ?string $icon = null,
public bool $openInNewTab = false,
) {}
public function isRenderable(): bool
{
return $this->visible
&& trim($this->label) !== ''
&& (filled($this->url) || filled($this->actionName));
}
/**
* @return array{
* label: string,
* placement: string,
* url: ?string,
* actionName: ?string,
* destructive: bool,
* requiresConfirmation: bool,
* visible: bool,
* icon: ?string,
* openInNewTab: bool
* }
*/
public function toArray(): array
{
return [
'label' => $this->label,
'placement' => $this->placement,
'url' => $this->url,
'actionName' => $this->actionName,
'destructive' => $this->destructive,
'requiresConfirmation' => $this->requiresConfirmation,
'visible' => $this->visible,
'icon' => $this->icon,
'openInNewTab' => $this->openInNewTab,
];
}
}