vendredi 29 avril 2016

Eloquent pivot : how to do select columns in Laravel 5.1

I have two models Bill & Order, I can get Orders records via :

    $orders = $bill->orders;

But I want to use select like this :

 $orders = $bill->orders->select([
                            'orders.*',                            
                            \DB::raw('sum(orders.quantity) as qty'),
                            \DB::raw('sum(orders.price) as  total')                            
                            ]) 
                            ->groupBy('article_id');

I get this error :

Method select does not exist.

Please any one may help me, thanks !



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire