42 lines
1.4 KiB
PHP
42 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Requests\Bo\Slides;
|
|
|
|
use App\Actions\Slides\UpdateSlideInput;
|
|
use App\Models\Slide;
|
|
|
|
class UpdateSlideRequest extends StoreSlideRequest
|
|
{
|
|
public function toUpdateSlideInput(Slide $slide): UpdateSlideInput
|
|
{
|
|
return new UpdateSlideInput(
|
|
slide: $slide,
|
|
title: $this->string('title')->value(),
|
|
text: $this->filled('text') ? $this->string('text')->value() : null,
|
|
picture: $this->resolvePicture(),
|
|
pictureAlt: $this->filled('picture_alt') ? $this->string('picture_alt')->value() : null,
|
|
pictureTitle: $this->filled('picture_title') ? $this->string('picture_title')->value() : null,
|
|
link: $this->filled('link') ? $this->string('link')->value() : null,
|
|
linkLabel: $this->filled('link_label') ? $this->string('link_label')->value() : null,
|
|
linkNewTab: $this->boolean('link_new_tab'),
|
|
connected: $this->boolean('connected'),
|
|
period: $this->toDatePeriod(),
|
|
);
|
|
}
|
|
|
|
#[\Override]
|
|
public function rules(): array
|
|
{
|
|
$rules = parent::rules();
|
|
|
|
/** @var \App\Models\Slide|null $slide */
|
|
$slide = $this->route('slide');
|
|
if ($slide && ! empty($slide->picture)) {
|
|
$rules['text'] = ['nullable', 'string', 'min:4'];
|
|
}
|
|
|
|
return $rules;
|
|
}
|
|
}
|