0
我敢肯定我錯過了一些非常明顯的東西,但看不到分部名稱出現在我的視圖中。Laravel模型查看 - 未定義變量
它使返回未定義變量:division_name
DIVISON.PHP(型號)
<?php
class Division extends \Eloquent {
protected $table = 'divisions';
public function scopeGetDivisionName($query, $slug)
{
return $query->select('division_name')
->join('division_industry_job', 'division_industry_job.division_id', '=', 'divisions.id')
->join('industryjobs', 'division_industry_job.industry_job_id', '=', 'industryjobs.id')
->where('industryjobs.slug', '=', $slug);
}
}
JOBCONTROLLER.PHP(控制器)
public function showdivisionjob($slug)
{
$job = IndustryJob::where("slug", "=", $slug)->first();
$division_name = Division::getDivisionName($slug)->firstOrFail();
return View::make('job')->with('job', $job, $division_name);
}
JOB.BLADE.PHP(查看)
{{$division_name->division_name}}
{{$job->job_title}}
轟!而已。謝謝! – user3189734