Reputation: 1179
I have this controller:
public function show($id)
{
$restaurant = Restaurant::find($id);
return View::Make('restaurants.profile')->with('restaurant', $restaurant);
}
In the view, I am trying to use the restaurant
variable as this:
<li>
<label>Name</label>
<div class="oneInfo">
<label>$restaurant->id</label>
</div>
</li>
But I just got the world $restaurant->id
printed on my browser, I should have got the value of the ID, right?
what am I doing wrong please? How can I solve it?
Many thanks
Upvotes: 1
Views: 4327
Reputation: 551
First of all you forgot to wrap this {{ $restaurant->id }} around your code from the controller. And before this can work in your view you must save your view to work with the blade templating engine. like so page-name.blade.php. Honestly i have done earlier projects without blade and you must use the normal php tags in case you decide to go the usual php syntax. But blade keep things organized and maintainable. Simple and less code, this keeps your view clean. http://laravel.com/docs/templates
Upvotes: 1
Reputation: 276
You should use {{
and }}
as a wrapper around server-side code. In pure PHP and some other frameworks, the markup is <?php echo $restaurant->id ?>
This is how the server knows if it needs to execute some PHP code.
<li>
<label>Name</label>
<div class="oneInfo">
<label>{{ $restaurant->id }}</label>
</div>
</li>
Upvotes: 2