laravel DB,从表中获取所有数据


laravel DB, get all data form tables

欢迎,我试图通过"with"将laravel中的几个表中的数据组合起来。我目前有这样一个东西,我不知道如何做到这一点。第二次调用是表1 的主要关键字

 $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', '=', ??);

    }]);

如何将id配置文件从查询插入到msg_profils中的"??"?

$profil->with('msg_profils'),就足够了,因为Laravel会自动匹配外键。