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個對象其實有數據)。