I am laravel beginer. i am not able to understand this code.
<option value="1" {{ !empty($make->status)?($make->status==1)? 'selected':'':'selected' }} >Active
please help with if else statement.
I am laravel beginer. i am not able to understand this code.
<option value="1" {{ !empty($make->status)?($make->status==1)? 'selected':'':'selected' }} >Active
please help with if else statement.
This code:
!empty($make->status)?($make->status==1)? 'selected':'':'selected'
can be written out in long form as
if (!empty($make->status) {
if ($make->status == 1) {
echo "selected";
}
else {
}
else {
echo "selected";
}
So the option will be selected if $make->status
is empty, or if it's not empty and its value is 1.
As written, the code is relying on operator precedence and would be much easier to understand if it was written with parentheses:
!empty($make->status) ? ($make->status==1 ? 'selected':'') : 'selected'