This question already has answers here:
Answer
Solution:
use old('parent_id') ?? $category['parent_id'] ?? ''
{!! General::selectMultiLevel('parent_id', $categories, ['class' => 'form-control', 'selected' => old('parent_id') ?? $category['parent_id'] ?? '', 'placeholder'=>'---Chose Category---' ]) !!}
Answer
Solution:
This issue is due to nested ternaries, which in my opinion is extremely difficult to read!
As the message states, avoid nested ternaries where precedence is not enforced by parenthesis.
From your code:
{!! General::selectMultiLevel('parent_id', $categories, [
'class' => 'form-control',
'selected' => !empty(old('parent_id')) ? old('parent_id') : !empty($category['parent_id']) ? $category['parent_id'] : '',
'placeholder'=>'---Chose Category---' ])
!!}
The issue lies within the 'selected' key. replacing
!empty(old('parent_id')) ? old('parent_id') : !empty($category['parent_id']) ? $category['parent_id'] : ''
with
!empty(old('parent_id')) ? old('parent_id') : (!empty($category['parent_id']) ? $category['parent_id'] : '')
Notice the additional parenthesis after the first :
But maybe consider using complete if statements for nested blocks for readability.
Source