jeudi 12 décembre 2019

Laravel how to count values from one table with multiple joins

In the Below Code i was using multiple table joins and i have multiple rows with the same id from the table clients_topup table while i need to count multiple rows from the table and display all data from the other two tables

in the below code i was getting only count values how to make it out

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

            $users[] = $clientsLevelOne;
          }


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire