Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function show(Project $project){
- ....$projectsindustries = DB::table('projects_industries')->select('*')->where('projects_id', $project->id)->get();
- ....$industries = Industry::all();
- ....return view('projects.show', compact('project', 'projectsindustries', 'industries'));
- }
- @if($projectsindustries)
- ....<ul>
- ........@foreach($projectsindustries as $projectindustry)
- ............@foreach($industries as $industry)
- ................<li><a href="#">{{ $industry::where('id', '=', '$projectindustry->industries_id')->get()->name; }}</a></li>
- ............@endforeach
- ........@endforeach
- ....</ul>
- @else
- ....<p>no industries.</p>
- @endif
- <?php namespace AppHttpControllers;
- use DB;
- use AppProject;
- use AppProjectIndustry;
- use AppIndustry;
- public function show(Project $project)
- {
- $projectsindustries = ProjectIndustry::where('projects_id', '=', $project->id)
- ->join('industries', 'industries_id', '=', 'industries.id')->get();
- return view('projects.show', compact('project', 'projectsindustries'));
- }
- public function industries() {
- return $this->belongsToMany('Industry', 'projects_industries', 'projects_id', 'industries_id');
- }
- protected $table = 'projects_industries';
- public function project()
- {
- return $this->belongsTo('Project', 'id', 'projects_id');
- }
- public function industry()
- {
- return $this->hasMany('Industry', 'id', 'industries_id');
- }
- <?php namespace App;
- use IlluminateDatabaseEloquentModel;
- class Industry extends Model {
- public function project()
- {
- return $this->belongsTo('Project');
- }
- }
- @if($projectsindustries)
- <h3>Industries:</h3>
- <ul>
- @foreach($projectsindustries as $projectindustry)
- <li><a href="{{ route('industries.show', $projectindustry->slug) }}">{{ $projectindustry->name }}</a></li>
- @endforeach
- </ul>
- @else
- <p>no industries.</p>
- @endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement