jeudi 19 décembre 2019

Select profile from one Table and count rows from another table using laravel

using laravel fetch all columns from profile table and on left join fetch profile image from another table and using select count of amount from payment table while payment have multiple columns of amount while these three tables have common column as user id how to make this function in laravel controller

 $clientsLevelOne = DB::table('clients')
            ->select(DB::raw("SUM((payment_amount).topup_amount) as count"))
            ->leftjoin('clients_payment_type','clients_payment_type.user_id', '=', 'clients.id')
            ->leftjoin('clients_topup', 'clients_topup.user_id', '=', 'clients.id')
            ->where('clients.under_reference','=',$client->reference_id)
            ->whereIn('client_id', $client_id_list)
            ->groupBy('client_id')
            ->get();


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire