Reputation: 101
@foreach($pizzas as $pizza)
<div>
<h3> You ordered {{$pizza['type']}} pizza for {{$pizza['price']}} rupees; </h3>
@if({{$pizza['price']}} > 50)
<p>This Pizza is Expensive</p>
@elseif({{$pizza->['price']}} < 50)
<p>This Pizza is lower price</p>
@elseif({{$pizza->['price']}} == 50)
<p>This Pizza is everage price</p>
@endif
</div>
@endforeach
I know to do this in php. but how to do this in laravel. i'm beginner to laravel. So i'm getting syntax error. please help to go ahead. Thank you...
This is the syntex error
syntax error, unexpected '<' (View:
C:\xampp\htdocs\laravel\pizzahouse\resources\views\pizza.blade.php)
Upvotes: 0
Views: 66
Reputation: 1556
this line :
@if({{$pizza['price']}} > 50)
should be :
@if($pizza['price'] > 50)
Upvotes: 1
Reputation: 159
change this:
@foreach($pizzas as $pizza)
<div>
<h3> You ordered {{$pizza['type']}} pizza for {{$pizza['price']}} rupees; </h3>
@if($pizza['price'] > 50)
<p>This Pizza is Expensive</p>
@elseif($pizza['price'] < 50)
<p>This Pizza is lower price</p>
@elseif($pizza['price'] == 50)
<p>This Pizza is everage price</p>
@endif
</div>
@endforeach
you cant acces to array with this : ->
Upvotes: 0
Reputation: 5358
You do not need to use the opening {{
and closing }}
tags for variables inside the @if
statements. And also you are using the wrong notation to access arrays.
@foreach($pizzas as $pizza)
<div>
<h3> You ordered {{$pizza['type']}} pizza for {{$pizza['price']}} rupees; </h3>
@if($pizza['price'] > 50)
<p>This Pizza is Expensive</p>
@elseif($pizza['price'] < 50)
<p>This Pizza is lower price</p>
@elseif($pizza['price'] == 50)
<p>This Pizza is everage price</p>
@endif
</div>
@endforeach
Upvotes: 2