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

controller:

public function show(Project $project) 
{
	
	$industries = Industry::join('project_industries', 'project_industries.industry_id', '=', 'industries.id')
							->join('projects', 'projects.id' ,'=', 'project_industries.project_id')
							->where('projects.id', '=', $projectID)
							->get(['industries.id AS id', 'industries.name AS name');
	return view('projects.show', compact('project', 'industries'));
}

view

@if(count($industries)!=0)
	<ul>
		@foreach($industries as $industry)
			<li><a href="#">{{ $industry->name }}</a></li>
		@endforeach
	</ul>
@else
	<p> no industries! </p>
@endif
Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

scuderrr scuderrr Joined 5 Jun 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.