mercredi 28 février 2018

How to make leftjoin in laravel 5.4

I have two table 1)clients 2)orders. I trying to make leftjoin but I not getting correct result what i want. Please see image below.

Thanks

ClientController.php

$clients = Client::leftjoin('orders','orders.client_id','=','clients.id')
                    ->select(DB::raw("count(orders.id) as orderCount"),
                    'clients.name as name','clients.email as email',
                    'clients.phone as phone','clients.country as country',
                    'orders.total_amount')
                    ->where('orders.status',0)
                    ->get();

enter image description here



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

Aucun commentaire:

Enregistrer un commentaire