lundi 19 août 2019

How count a column from a tableB where tableA.y = TableB.y laravel

i would to count number of courses and question of each modules when i try with this code below he display the counting of all questions `

 //$data = DB::table('module')->orderBy('idmodule', 'desc')->paginate(5);

 $data = DB::table('module')
 ->leftJoin('cours', 'module.idmodule', '=', 'cours.id_module')
 ->leftJoin('question', 'cours.id_cours', '=', 'question.id_cours')
 ->select('module.*', 'cours.*',DB::raw("count(cours.id_module) as cours"),DB::raw("count(question.id_cours) as quest"))
 ->groupBy('module.idmodule')
 ->get();





    $id = Auth::id();
    return view('admin.modules',compact('data'))->with('profile',profile::find($id));


}`



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Mqg6nl
via IFTTT

Aucun commentaire:

Enregistrer un commentaire