This is a really odd error. In my blade view:
<?php //dd($site); ?>
@if($site==='site1')
On the second line @if($site==='site1') I get a Undefined variable: site error. But if I uncomment out the dump and die I get the $site variable set. It's literally on the very next line that it tells me it doesn't have a set $site variable in blade. Is my syntax wrong on the if statement?
It looks correct to me, the documentation gives:
@if (count($records) === 1)
I have one record!
@elseif (count($records) > 1)
I have multiple records!
@else
I don't have any records!
@endif
Adding a space between @if and the first paren ( made no difference.
I tried clearing the view cache but that made no difference too. Every other change gets registered, for example if I remove the $ that prepends the variable name I get an undefined constant error. I'm developing locally.
I'm at a complete loss because even though the variable is three levels deep in blade I am passing it correctly and I confirmed it with the dump and die. The conditional just won't pick it up.
I pass it into the view like this:
@component('pages.common.component.mycomponent',['site'=>$site])
@endcomponent
And one more level up like this:
@component('pages.common.parent.mycomponent',['site'=>'site1'])
@endcomponent
Any ideas I would be very grateful for!
EDIT:
The dd() call outputs:
"site1"
As a string.
?>and move it below the second line, it won't be valid, as the second line is blade syntax not php syntax. If I move the entire first line below the second line I just get the error before it hits the dump and die. Maybe I am misunderstanding you though.dd($site);?