WIP uploading files

This commit is contained in:
2026-04-29 19:40:37 +03:00
parent e058ceadee
commit bd01e5c32c
15 changed files with 506 additions and 362 deletions
+13 -22
View File
@@ -11,7 +11,6 @@ final class Channel
{
public string $lucentUrl;
public string $filesUrl;
public array $disks;
public string $previewTargetUrl;
/**
@@ -19,37 +18,29 @@ final class Channel
* @param Collection<UserCommand> $commands
*/
function __construct(
public string $name,
public string $url,
public string $previewTarget,
public string $name,
public string $url,
public string $previewTarget,
public Collection $commands,
public Collection $schemas,
public array $imageFilters,
public array $roles,
)
{
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 => ""
"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;
}, []);
}
}
+1 -1
View File
@@ -4,7 +4,7 @@ namespace Lucent\Channel;
use Lucent\Channel\Data\UserCommand;
use Lucent\Primitive\Collection;
use Lucent\Schema\Schema;
use Lucent\Data\Schema;
use Lucent\Schema\SchemaService;
use PhpOption\Option;