Files
lucent-laravel/src/Channel/Channel.php
T

48 lines
1.3 KiB
PHP
Raw Normal View History

2023-10-02 23:10:49 +03:00
<?php
namespace Lucent\Channel;
2024-08-24 18:51:36 +03:00
use Lucent\Channel\Data\UserCommand;
2023-10-02 23:10:49 +03:00
use Lucent\Primitive\Collection;
use Lucent\Schema\Schema;
final class Channel
{
public string $lucentUrl;
public string $filesUrl;
2023-10-06 13:07:09 +03:00
public string $previewTargetUrl;
2023-10-02 23:10:49 +03:00
/**
* @param Collection<Schema> $schemas
2024-08-24 18:51:36 +03:00
* @param Collection<UserCommand> $commands
2023-10-02 23:10:49 +03:00
*/
function __construct(
2026-04-29 19:40:37 +03:00
public string $name,
public string $url,
public string $previewTarget,
2024-08-24 18:51:36 +03:00
public Collection $commands,
2023-10-02 23:10:49 +03:00
public Collection $schemas,
2026-04-29 19:40:37 +03:00
public array $imageFilters,
public array $roles,
) {
2023-10-02 23:10:49 +03:00
$this->lucentUrl = $url . "/lucent";
2024-08-23 20:58:45 +03:00
$this->filesUrl = $this->makeFilesUrl();
2026-05-05 19:21:59 +03:00
2024-08-23 20:58:45 +03:00
$this->previewTargetUrl = $url . "/" . $previewTarget;
}
private function makeFilesUrl(): string
{
2026-05-05 19:21:59 +03:00
$lucentDisk = config("lucent.disk");
return match (config("filesystems.disks.$lucentDisk.driver")) {
"s3" => config("filesystems.disks.$lucentDisk.endpoint") .
2026-04-29 19:40:37 +03:00
"/" .
2026-05-05 19:21:59 +03:00
config("filesystems.disks.$lucentDisk.bucket"),
2026-04-29 19:40:37 +03:00
"local" => $this->url .
"/storage" .
2026-05-05 19:21:59 +03:00
config("filesystems.disks.$lucentDisk.endpoint"),
2026-04-29 19:40:37 +03:00
default => "",
2024-08-23 20:58:45 +03:00
};
2024-09-27 14:28:20 +03:00
}
2023-10-02 23:10:49 +03:00
}