Laravel orm多對多關係如何獲得中間表的附加欄位的內容?
仅有的幸福
仅有的幸福 2017-05-16 16:47:36
0
1
363
###桌子:### 雷雷
仅有的幸福
仅有的幸福

全部回覆(1)
过去多啦不再A梦

大致這個樣子,定義模型關係的時候

return $this->belongsToMany('App\Role')->withPivot('column1', 'column2');

取得數據的時候

$user = App\User::find(1);

foreach ($user->roles as $role) {
    echo $role->pivot->column1;
}


熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板