The error most likely comes from this line
old('filters')[$filter->id] ===
//try giving it a fallback
old('filters')[$filter->id] ?? 0 ===
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have the above error, I already tried using the
@foreach(optional($filter->filter_values) as $filter_value)
Based on some of the solutions I can accross, with this the error is fixed and the thing now is nothing returns in the array even when they are not empty. I must have put the "optional" in the wrong place as when I remove it the error is thrown again
@foreach($filters as $filter)
<div class="input__field">
<div class="select">
<label for="{{ $filter->alias }}">{{ $filter->name }}:</label>
<select class="js_pretty_select js__select__{{ $filter->alias }} select__{{ $filter->alias }}" id="{{ $filter->alias }}" name="filters[{{ $filter->id }}]">
<option value="0">--- Select value ---</option>
@foreach($filter->filter_values as $filter_value)
<option value="{{ $filter_value->id }}" @if(in_array($filter_value->id, $filterValuesIds) || old('filters')[$filter->id] ?? 0 === $filter_value->id) selected @endif>{{ optional($filter_v
@endforeach
</select>
</div>
</div>
@endforeach
Please any help will great, thanks
@DavP2021 This the same error? Maybe try wrapping it. It works for me in tinker
(old('filters')[$filter->id] ?? 0)
Please or to participate in this conversation.