$schemas * @param Collection $commands */ function __construct( public string $name, public string $url, public string $previewTarget, public Collection $commands, public Collection $schemas, public array $imageFilters, public array $roles, ) { $this->lucentUrl = $url . "/lucent"; $this->filesUrl = $this->makeFilesUrl(); $this->disks = $this->getDisksFromSchemas(); $this->previewTargetUrl = $url . "/" . $previewTarget; } private function makeFilesUrl(): string { return match (config("filesystems.disks.lucent.driver")) { "s3" => config("filesystems.disks.lucent.endpoint") . "/" . config("filesystems.disks.lucent.bucket"), "local" => $this->url . "/storage" . config("filesystems.disks.lucent.endpoint"), default => "" }; } private function getDisksFromSchemas() { return $this->schemas->filter(fn(Schema $schema) => get_class($schema) === FilesSchema::class)->reduce(function (array $carry, Schema $schema) { $carry[$schema->disk] = config("filesystems.disks." . $schema->disk . ".url"); return $carry; }, []); } }