【发布时间】:2015-11-24 10:23:22
【问题描述】:
我试图在我的模板中显示两个表的列,但我没有成功
模板:
@foreach ($LatestSeeker_list_adv as $ads)
<span>ads id</span><span>{{ $ads->advertise->id }}</span>
<span>inf id</span><span>{{ $ads->information->id }}</span>
@endforeach
控制器:
public function SeekerLatest()
{
$LatestSeeker_list = Advertise_Model::with('information')->get();
return view('Users.Seeker.LatestAds.index',compact('LatestSeeker_list'));
}
广告模型:
public function Information()
{
return $this->hasOne('App\Information_Model');
}
信息模型:
public function Advertise()
{
return $this->belongsTo('App\Advertise_Model');
}
宣传迁移:
Schema::table('advertise', function($table) {
$table->foreign('information_id')->references('id')->on('information');
});
错误:
SQLSTATE[42S22]:未找到列:1054 未知列 “where 子句”中的“information.advertise__model_id”(SQL:选择 * 来自
information其中information.advertise__model_idin (1, 2))
【问题讨论】:
标签: php mysql laravel laravel-5