ldc-wenn-dann-mit-respekt/resources/views/bo/modules/minicrud-form-inputs.blade.php
2023-03-24 15:39:11 +00:00

140 lines
7.1 KiB
PHP

{{-- MINI CRUD EDIT --}}
@php
$data = (isset($model->data)) ? $model->getEmptyData() : $conceptData;
@endphp
@foreach ($data as $k => $input)
@php
$input = json_decode(json_encode($input), true);
@endphp
@switch(intval($input['inputType']))
@case(intval(App\Enums\InputType::url->value))
@case(intval(App\Enums\InputType::string->value))
<div class="col-12 col-md-6 mb-3">
<fieldset class="border h-100 bg-white p-3">
<legend>{{ $input['label'] }} *</legend>
<div class="row">
<div class="col-12 mb-3">
@include('bo.partials.inputs.varchar', [
'id' => Str::slug($input["label"]),
'label' => $input['label'] . ' of the ' . __('models.classes.concepts'),
'hasWordCounter' => true,
'name' => 'data['.$k.'][value]',
'value' => $model->data->{$k}->value ?? null,
'required' => true,
'model' => $model ?? null,
'helper' => __('Must be in 3 characters minimum, 255 maximum.')
])
</div>
</div>
</fieldset>
</div>
@break
@case(intval(App\Enums\InputType::number->value))
<div class="form-group">
<label for="{{ $k }}"><small>{{ $input['label'] }}*</small></label>
<input id="{{ $k }}" type="number" step="0.01" class="form-control"
name="data[{{ $k }}][value]" placeholder="{{ $input['label'] }}"
value="{{ old("data.$k.value") ?? ($input['value'] ?? '') }}" required>
</div>
@break
@case(intval(App\Enums\InputType::text->value))
<div class="col-12 mb-3">
<fieldset class="border bg-white p-3">
<legend>{{ $input['label'] }} *</legend>
<div class="row mb-3">
<div class="col-12">
@include('bo.partials.inputs.text-html', [
'id' => Str::slug($input["label"]),
'name' => 'data['.$k.'][value]',
'value' => $model->data->{$k}->value ?? null,
'model' => $model ?? null,
])
</div>
</div>
</fieldset>
</div>
@include('modules.input-error', ['inputName' => 'data['.$k.'][value]'])
@break
@case(intval(App\Enums\InputType::boolean->value))
@case(intval(App\Enums\InputType::image->value))
<div class="col-12 mb-3">
<fieldset class="border h-100 bg-white p-3">
<legend>{{ $input['label'] }} *</legend>
<div class="row">
{{-- PICTURE_ALT --}}
<div class="col-12 col-md-6 mb-3">
@include('bo.partials.inputs.varchar', [
'id' => Str::slug($input["label"]) . '-alt',
'label' => __('Alt attribute of the image'),
'hasWordCounter' => true,
'name' => 'data['.$k.'][alt]',
'value' => $model->data->{$k}->alt ?? null,
'required' => true,
'model' => $model ?? null,
'helper' => __('Must describe your image for search engines and blind people (5 to 6 words, minimum 3 characters).'),
])
</div>
{{-- PICTURE_TITLE --}}
<div class="col-12 col-md-6 mb-3">
@include('bo.partials.inputs.varchar', [
'id' => Str::slug($input["label"]) . '-title',
'label' => __('Title attribute of the image'),
'hasWordCounter' => true,
'name' => 'data['.$k.'][title]',
'value' => $model->data->{$k}->title ?? null,
'required' => true,
'model' => $model ?? null,
'helper' => __('Useful for users, displayed by moving the mouse over the image (minimum 3 characters).'),
])
</div>
{{-- PICTURE --}}
<div class="col-12 mb-3">
@include('bo.partials.inputs.varchar-picture', [
'id' => Str::slug($input["label"]),
'name' => 'data['.$k.'][value]',
'width' => $input['dimensions']['width'],
'height' => $input['dimensions']['height'],
'model' => $model ?? null,
'value' => $model->data->{$k}->value ?? null,
'helper' => __('Must be :widthpx (width) by :heightpx (height).', [
'width' => $input['dimensions']['width'],
'height' => $input['dimensions']['height'],
]),
'required' => true,
'preview' => true,
])
</div>
</div>
</fieldset>
</div>
@break
@case(intval(App\Enums\InputType::imageArray->value))
@case(intval(App\Enums\InputType::labelArray->value))
@case(intval(App\Enums\InputType::selectEnum->value))
<div class="col-12 col-md-6 mb-3">
<fieldset class="border h-100 bg-white p-3">
<legend>{{ $input['label'] }} *</legend>
<div class="row">
<div class="col-12 mb-3">
@include('bo.partials.inputs.select-enum', [
'id' => Str::slug($input["label"]),
'label' => $input['label'] . ' associated',
'name' => 'data['.$k.'][value]',
'model' => $model ?? null,
'require' => true,
'associatedModels' => $selectedEnum ?? [],
'helper' => trans('Selectionnez un :enum parmis la liste.', ['enum' => $input['label']]),
])
</div>
</div>
</fieldset>
</div>
@break
@default
@php throw new Exception('Input type not handled'); @endphp
@endswitch
@endforeach