ldc-cocotte/app/Http/Requests/Bo/Slides/UpdateSlideRequest.php
Jérémy Munsch d0efb0f527
refactor: update namespaces for actions and queries
Refactored the codebase to change the namespaces of various actions and queries from `App\Actions` to `App\Cqs\Actions` and `App\Queries` to `App\Cqs\Queries`. This restructuring improves organization and clarity in the codebase.
2026-11-10 15:13:26 +01:00

42 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Http\Requests\Bo\Slides;
use App\Cqs\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;
}
}