Support the ongoing development of Laravel.io →
Eloquent Views Blade
Last updated 2 years ago.
0

Controller

public class ProductsController extends BaseController {

       public function getIndex() {
             $products = Product::with('category')->get();
             return View::make('products', $products);
       }
}

View

@foreach ($products as $product)
{{ $product->name }}
{{ $product->category->name}}
@endforeach
0

Thanks a lot Torch

0

Sign in to participate in this thread!

Eventy

Your banner here too?

manatech manatech Joined 7 Dec 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.