@foreach($fields as $field => $props)
@if($props['type'] != 'hidden')
{{$props['title']}} {!!isset($props['required'])&&$props['required'] ? '* ':''!!}
@endif
@switch($props['type'])
@case('hidden')
@break
@case('text')
@case('email')
@case('number')
@case('tel')
@break
@case('date')
@break
@case('datetime')
@break
@case('textarea')
@break
@case('select')
@php
$__selected = (isset($item->{$field}) && $item->{$field} !== '' && $item->{$field} !== null)
? $item->{$field}
: ($props['default'] ?? null);
@endphp
-- Select {{$props['title']}} --
@foreach($props['values'] as $k => $v)
{{$v}}
@endforeach
@break
@case('multiselect')
@php
$__selectedList = (isset($item->{$field}) && is_array($item->{$field}) && count($item->{$field}))
? $item->{$field}
: ($props['default'] ?? []);
@endphp
-- Select {{$props['title']}} --
@foreach($props['values'] as $k => $v)
{{$v}}
@endforeach
@break
@case('image')
@break
@case('multiimage')
@break
@case('file')
@break
@case('ranking_attributes')
@php
$rankingRows = [];
if ($mode === 'edit') {
$rawRanking = $item->ranking_attributes ?? null;
if (is_string($rawRanking) && $rawRanking !== '') {
$decodedRanking = json_decode($rawRanking, true);
$rawRanking = is_array($decodedRanking) ? $decodedRanking : [];
}
if (is_object($rawRanking)) {
$rawRanking = json_decode(json_encode($rawRanking), true);
}
if (is_array($rawRanking)) {
foreach ($rawRanking as $rankRow) {
if (is_object($rankRow)) {
$rankRow = (array) $rankRow;
}
if (!is_array($rankRow)) {
continue;
}
$rowCode = trim((string) ($rankRow['code'] ?? ''));
$rowValue = array_key_exists('value', $rankRow)
? trim((string) $rankRow['value'])
: '';
if ($rowCode === '') {
continue;
}
$rankingRows[] = [
'code' => $rowCode,
'value' => $rowValue,
];
}
}
}
$rankingAttrMeta = $props['attributes_meta'] ?? [];
$optionAttrTypes = ['select', 'multiselect', 'checkbox', 'radio'];
@endphp
Filter ranking by user attributes. Add multiple filters; each needs an attribute and value.
Add Filter
@if(count($rankingRows) > 0)
@endif
@foreach($rankingRows as $rankRow)
@php
$rowCode = $rankRow['code'];
$rowValue = $rankRow['value'];
$rowMeta = $rankingAttrMeta[$rowCode] ?? null;
$useOptions = $rowMeta
&& in_array(($rowMeta['type'] ?? ''), $optionAttrTypes, true)
&& !empty($rowMeta['options']);
@endphp
-- Select Attribute --
@if($rowCode !== '' && !isset($props['attributes'][$rowCode]))
{{ $rowCode }}
@endif
@foreach(($props['attributes'] ?? []) as $attrCode => $attrLabel)
{{ $attrLabel }}
@endforeach
@if($useOptions)
-- Select Value --
@if($rowValue !== '' && !isset($rowMeta['options'][$rowValue]))
{{ $rowValue }}
@endif
@foreach($rowMeta['options'] as $optVal => $optLabel)
{{ $optLabel }}
@endforeach
@else
@endif
@endforeach
@break
@case('mapping')
Add Metric
@break
@case('combined_metrics')
Add Metric
@break
@endswitch
@if($props['type'] != 'hidden')
@endif
@endforeach