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
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community