Add missing elements on Slider fom like type

This commit is contained in:
Jérémy Munsch 2022-06-27 17:17:03 +02:00
parent 22d31052e2
commit 5a1b1a84db
No known key found for this signature in database
GPG key ID: 18361AF3BFEC0FEC
4 changed files with 41 additions and 4 deletions

View file

@ -3,6 +3,7 @@
namespace App\Http\Requests\Bo\Sliders;
use App\Enums\Sliders\SliderPosition;
use App\Enums\Sliders\SliderType;
use App\Traits\Requests\HasPicture;
use Illuminate\Foundation\Http\FormRequest;
use Kwaadpepper\Enum\Rules\EnumIsValidRule;
@ -48,6 +49,10 @@ class StoreSliderRequest extends FormRequest
'title' => 'required|min:3|max:255',
'title_color' => 'required|color_hex',
'title_color_bg' => 'required|color_hex',
'subtitle' => 'required|min:3|max:255',
'subtitle_color' => 'required|color_hex',
'subtitle_color_bg' => 'required|color_hex',
'type' => ['required', new EnumIsValidRule(SliderType::class)],
'position' => ['required', new EnumIsValidRule(SliderPosition::class)],
'link' => 'required|url',
'link_title' => 'required|min:3|max:255',

View file

@ -4,4 +4,15 @@ namespace App\Http\Requests\Bo\Sliders;
class UpdateSliderRequest extends StoreSliderRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$rules = parent::rules();
unset($rules['type']);
return $rules;
}
}

View file

@ -18,7 +18,7 @@
<div class="col">
<h1 class="col h4">
<a href="{{ route('bo.sliders.index') }}" class="text-decoration-none btn btn-sm btn-primary" role="button" aria-roledescription="{{ _('Revenir en arrière') }}"><i class="fa-solid fa-arrow-left-long"></i></a>
<span>&nbsp;{{ __('models.classes.sliders') }}&nbsp;{{ __('édition') }}</span>
<span>&nbsp;{{ __('models.classes.sliders') }}&nbsp;{{ __('édition') }} -> {{ $slider->type->label }}</span>
</h1>
</div>
<div class="col text-end">

View file

@ -1,3 +1,24 @@
@if(!isset($slider) and count(App\Enums\Sliders\SliderType::toArray()) > 1)
<div class="row">
<div class="col">
<fieldset class="border p-3 mb-3">
<div class="col-12 col-md-6 form-group">
<label for="sliderType" class="col-form-label"><b>{{ __('Type de slider') }}</b></label>
<select id="sliderType" class="form-select" name="type" aria-describedby="sliderTypeHelp" required>
<option value="" @if(is_null(old('type', $slider->type ?? null))) selected @endif disabled>{{ __('Séléctionnez un type') }}</option>
@foreach(App\Enums\Sliders\SliderType::toArray() as $type)
<option value="{{ $type->value }}" @if(old('type', optional($slider->type ?? null)->value) == $type->value) selected @endif>{{ $type->label }}</option>
@endforeach
</select>
@include('back.modules.input-error', [
'inputName' => 'type', 'helperId' => 'sliderTypeHelp' , 'helper' => __('Le type de slider à créer')
])
</div>
</fieldset>
</div>
</div>
@endif
<div class="row">
<div class="col">
<fieldset class="border p-3 mb-3">
@ -47,7 +68,7 @@
</div>
<div class="col-12 col-md-6">
<div class="form-group">
<label for="sliderSubTitleColor"><b>{{ __('Couleur du titre') }}</b></label>
<label for="sliderSubTitleColor"><b>{{ __('Couleur du sous-titre') }}</b></label>
<input name="subtitle_color" type="color" class="form-control form-control-color" id="sliderSubTitleColor" value="{{ old('subtitle_color', $slider->subtitle_color ?? '') }}" title="{{ __('Choisi ta couleur') }}" aria-describedby="sliderSubTitleColorHelp">
@include('back.modules.input-error', [
'inputName' => 'subtitle_color', 'helperId' => 'sliderSubTitleColorHelp' , 'helper' => __('Couleur du sous-titre')
@ -56,7 +77,7 @@
</div>
<div class="col-12 col-md-6">
<div class="form-group">
<label for="sliderSubTitleBgColor"><b>{{ __('Couleur de fond du titre') }}</b></label>
<label for="sliderSubTitleBgColor"><b>{{ __('Couleur de fond du sous-titre') }}</b></label>
<input name="subtitle_color_bg" type="color" class="form-control form-control-color" id="sliderSubTitleBgColor" value="{{ old('subtitle_color_bg', $slider->subtitle_color_bg ?? '') }}" title="{{ __('Choisi ta couleur') }}" aria-describedby="sliderSubTitleBgColorHelp">
@include('back.modules.input-error', [
'inputName' => 'subtitle_color_bg', 'helperId' => 'sliderSubTitleBgColorHelp' , 'helper' => __('Couleur de fond du sous-titre')
@ -113,7 +134,7 @@
<div class="col-12 col-md-6 form-group">
<label for="sliderPicturePosition" class="col-form-label"><b>{{ __('Position de centrage') }}</b></label>
<select id="sliderPicturePosition" class="form-select" name="position" aria-describedby="sliderPicturePositionHelp" required>
<option value="" @if(is_null(old('position', $slider->position ?? null))) selected @endif disabled>{{ __('Séléctionnez un position de centrage') }}</option>
<option value="" @if(is_null(old('position', $slider->position ?? null))) selected @endif disabled>{{ __('Séléctionnez une position de centrage') }}</option>
@foreach(App\Enums\Sliders\SliderPosition::toArray() as $status)
<option value="{{ $status->value }}" @if(old('published', optional($slider->position ?? null)->value) == $status->value) selected @endif>{{ $status->label }}</option>
@endforeach