Support the ongoing development of Laravel.io →
Requests Database Laravel.io
Last updated 2 years ago.
0

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
0

Sign in to participate in this thread!

Eventy

Your banner here too?

soduno soduno Joined 3 May 2015

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.