I have an issue using @if
, @elseif
and @else
statement on blade.php using laravel 8, It always return as Undefined Variable. How can I resolve this problem? Or is there any other away around?
On my index.blade.php
:
@if($exi)
@include('renew.modify.exi')
@elseif($exi2)
@include('renew.modify.exi2')
@elseif($exp)
@include('renew.modify.exp')
@endif
On my modifyController.php
:
if (count((array) $exi) > 0) {
return View::make('renew.modify.index', ['exi' => $exi]);
}
elseif(count((array) $exi2) > 0) {
return View::make('renew.modify.index', ['exi2' => $exi2]);
}
elseif(count((array) $exp) > 0) {
return View::make('renew.modify.index', ['exp' => $exp]);
} else {
Session::flash('flash_message', 'Something went wrong on your credentials. Please double check your inputs. If you don\'t have any. You can create here: ');
return Redirect::to('renewView');
}
My goal is, when the controller detect that count((array) $something)
detect then it will return to the same index.blade then the @if, @elseif and @else
will be triggered, but when $exp
detected the my two variable will be undefined
. How do i resolve this problem?