2016-05-08 79 views
0

歡迎, 我嘗試通過「with」結合laravel中幾個表中的數據我現在有這樣的事情,我不知道如何做到這一點與第二個電話是表1的主要關鍵字laravel DB,獲取所有數據表格

$profil = Profil::where('ghost', Chat::GHOST_NO); 

    $profil->with(['avatar_profils' => function($query) { 
     $query->where('id_profil', '=', Session::get('profil')->id); 


    }]); 

    $profil->with(['msg_profils' => function($query) { 
     $query->where('id_profil', '=', ??); 


    }]); 

如何將查詢插入到「??」在msg_profils中?

+1

我相信''profil-> with('msg_profils')'就足夠了,因爲Laravel會自動匹配外鍵。 –

+0

所以正常工作謝謝:) – Matx132

+0

我寫評論作爲答案,請設置爲正確 –

回答

0

$profil->with('msg_profils'),就足夠了,因爲Laravel自動匹配外鍵。

相關問題