0
得到一个domain table
具有带有domain_hosts_table
,server_hosts_table
和systems_table
一个One To Many relationship
。到现在为止还挺好。关系返回错误/空数据(Laravel 5.2)
调用表中的数据:
$domains = Domain::with('domain_host', 'server_host', 'system')->get();
域型号:
public function domain_host()
{
return $this->hasOne('App\DomainHost', 'id');
}
public function server_host()
{
return $this->hasOne('App\ServerHost', 'id');
}
public function system()
{
return $this->hasOne('App\System', 'id');
}
DomainHost,SERVERHOST,系统型号:
public function domains()
{
return $this->hasMany('App\Domain');
}
域表:
到目前为止好。
让我们来看看这个特定的表返回的是foreached
。
第2行应该是(基础上其ID)相同,前2后的所有行都只是空的。
(dd
的取数据,注意在第4个对象空关系,第1个对象其实有数据)。