You can use
Controller
public function getMaster(){
$masters = MasterCategory::all();
return View::make('output_file',compact('masters')); // With Laravel 4
//return view('output_file',compact('masters')); // With laravel 5
}
Master Model
public function categories(){
return $this->hasMany('Category','masterCategory');
}
View
@foreach($masters as $master)
<h3>{{$master->name}}</h3>
@if($master->categories())
@foreach($master->categories() as $category)
<p>{{$category->name}}</p>
@endforeach
@endif
@endforeach
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community