2 回答

TA貢獻(xiàn)1797條經(jīng)驗(yàn) 獲得超6個(gè)贊
您可以使用關(guān)系獲取此詳細(xì)信息。在Clinic模型中,添加
public function locations()
{
return $this->belongsTo('App\Models\Locations','clinicID','clinicID');
}
在Locations模型中,添加,
public function location_services()
{
return $this->hasOne('App\Models\LocationServices','locationID','locationID');
}
在LocationServices模型上,
public function services()
{
return $this->hasOne('App\Models\Services','ServiceId','ServiceId');
}
您可以通過(guò)以下方式獲得結(jié)果,
$clinic_info = Clinic::find($id);
if(isset($clinic_info->locations))
{
if(isset($clinic_info->locations->location_services))
{
if(isset($clinic_info->locations->location_services->services))
{
echo $clinic_info->locations->location_services->services->ServiceName;
}
}
}

TA貢獻(xiàn)1795條經(jīng)驗(yàn) 獲得超7個(gè)贊
參考Maybe HelpFull為您服務(wù)
多連接
$data = DB::table('city') ->join('state', 'state.state_id', '=', 'city.state_id') ->join('country', 'country.country_id', '=', 'state.country_id') ->select('country.country_name', 'state.state_name', 'city.city_name') ->get(); return view('join_table', compact('data'));
- 2 回答
- 0 關(guān)注
- 155 瀏覽
添加回答
舉報(bào)