50 lines
1.4 KiB
PHP
50 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Actions\Slides;
|
|
|
|
use App\Contracts\ActionInput;
|
|
use Domain\Models\ValueObjects\DatePeriod;
|
|
use Illuminate\Http\UploadedFile;
|
|
use Webmozart\Assert\Assert;
|
|
|
|
final readonly class CreateSlideInput implements ActionInput
|
|
{
|
|
public function __construct(
|
|
public string $title,
|
|
public ?string $text = null,
|
|
public UploadedFile | string | null $picture = null,
|
|
public ?string $pictureAlt = null,
|
|
public ?string $pictureTitle = null,
|
|
public ?string $link = null,
|
|
public ?string $linkLabel = null,
|
|
public bool $linkNewTab = false,
|
|
public bool $connected = false,
|
|
public DatePeriod $period = new DatePeriod(),
|
|
) {
|
|
Assert::stringNotEmpty(trim($this->title));
|
|
Assert::maxLength($this->title, 75);
|
|
|
|
Assert::true(
|
|
$this->picture !== null || ($this->text !== null && trim($this->text) !== ''),
|
|
'A slide must have either a picture or text.'
|
|
);
|
|
|
|
if ($this->pictureAlt !== null) {
|
|
Assert::maxLength($this->pictureAlt, 75);
|
|
}
|
|
|
|
if ($this->pictureTitle !== null) {
|
|
Assert::maxLength($this->pictureTitle, 75);
|
|
}
|
|
|
|
if ($this->link !== null) {
|
|
Assert::maxLength($this->link, 255);
|
|
}
|
|
|
|
if ($this->linkLabel !== null) {
|
|
Assert::maxLength($this->linkLabel, 255);
|
|
}
|
|
}
|
|
}
|