refactor: ♻️ Use Switch state instead of elseif

This commit is contained in:
IceToast 2023-02-09 22:38:47 +01:00 committed by IceToast
parent ac5fa6c25c
commit 20f0e1dfc2

View file

@ -83,38 +83,52 @@
<i class="fas fa-info-circle mr-4 invisible"></i> <i class="fas fa-info-circle mr-4 invisible"></i>
@endif @endif
@if ($value['type'] == 'string') @switch($value)
<input type="text" class="form-control" @case($value['type'] == 'string')
name="{{ $key }}" value="{{ $value['value'] }}"> <input type="text" class="form-control"
@elseif ($value['type'] == 'boolean') name="{{ $key }}" value="{{ $value['value'] }}">
<input type="checkbox" name="{{ $key }}" @break
value="{{ $value['value'] }}">
@elseif ($value['type'] == 'number') @case($value['type'] == 'boolean')
<input type="number" class="form-control" <input type="checkbox" name="{{ $key }}"
name="{{ $key }}" value="{{ $value['value'] }}"> value="{{ $value['value'] }}">
@elseif ($value['type'] == 'select') @break
<select id="{{ $key }}" class="custom-select w-100"
name="{{ $key }}"> @case($value['type'] == 'number')
@foreach ($value['options'] as $option) <input type="number" class="form-control"
<option value="{{ $option }}" name="{{ $key }}" value="{{ $value['value'] }}">
{{ $value['value'] == $option ? 'selected' : '' }}> @break
{{ __($option) }}
</option> @case($value['type'] == 'select')
@endforeach <select id="{{ $key }}" class="custom-select w-100"
</select> name="{{ $key }}">
@elseif($value['type'] == 'multiselect') @foreach ($value['options'] as $option)
<select class="custom-select w-100" name="{{ $key }}" <option value="{{ $option }}"
multiple> {{ $value['value'] == $option ? 'selected' : '' }}>
@foreach ($value['options'] as $option) {{ __($option) }}
<option value="{{ $option }}" </option>
{{ $value['value'] == $option ? 'selected' : '' }}> @endforeach
{{ __($option) }} </select>
</option> @break
@endforeach
</select> @case($value['type'] == 'multiselect')
@elseif($value['type'] == 'textarea') <select id="{{ $key }}" class="custom-select w-100"
<textarea class="form-control w-100" name="{{ $key }}" rows="3">{{ $value['value'] }}</textarea> name="{{ $key }}" multiple>
@endif @foreach ($value['options'] as $option)
<option value="{{ $option }}"
{{ $value['value'] == $option ? 'selected' : '' }}>
{{ __($option) }}
</option>
@endforeach
</select>
@break
@case($value['type'] == 'textarea')
<textarea class="form-control" name="{{ $key }}" rows="3">{{ $value['value'] }}</textarea>
@break
@default
@endswitch
</div> </div>
</div> </div>