Join in DB::raw() laravel 4


Join in DB::raw() laravel 4

我的数据库中有3个表:

reponse[id,nomRep,#envoi_id]
envoi[id,#projet_id,#quest_id]
projet[id,nomProjet]

我想做的是使用以下代码获得我的项目的名称

 $days = Input::get('days', 7);
                  $range = 'Carbon'Carbon::now()->subDays($days);
            $chartt = DB::table('reponse')
                ->where('created_at', '>=', $range)
                ->groupBy('value')
                ->remember(1440)
                ->get([
                    DB::raw('envoi_id as nomProjet')// here where i want to get the name of my project,
                    DB::raw('etatSatisfaction as value')
                ]);
            return $chartt;

请帮忙吗?

这是我自己找到的答案,我想有人需要它:

  DB::raw(' (SELECT p.nom FROM projet p,ligneenvoi l WHERE rep.ligneenvoi_id=l.id AND l.projet_id=p.id) AS nomProjet ') ,