标签:code ssid type hasone data color $set one style
model
一表關聯二表
public function ordercode() { return $this->hasOne(\App\Models\OrderCode::class,‘id‘,‘ordercodeid‘); }
二表關聯三表
public function order() { return $this->hasOne(\App\Models\Order::class,‘id‘,‘orderid‘); }
controller
通過一表拿三表數據
//查詢數據 $settlement = new OrderCodeSettlement(); $dataTypeContent = $settlement->with(‘ordercode‘,‘ordercode.order‘)->SettlementBusinessId($id)->paginate($pa,[‘*‘],‘page‘, $curt_page); //輸出 foreach ($dataTypeContent as $val) { echo $val->ordercode->order->order_no.‘\n‘; }
laravel 一表關聯二表,二表關聯三表,通過一表controller拿三表數據
标签:code ssid type hasone data color $set one style
原文地址:https://www.cnblogs.com/clubs/p/10059039.html