mercredi 9 mars 2022

GroupBy not working in Laravel With Method

I use GroupBy query inside the WITH method in laravel query like following.

$q = Invoice::query();

     if($request->from_date){  $q->where('invoice_date','>=',date('Y-m-d',strtotime($request->from_date))); }

     if($request->to_date){ $q->where('invoice_date','<=',date('Y-m-d',strtotime($request->to_date))); }
    
     if($request->branch_id){ $q->where('branch_id',$request->branch_id); }

    $q->with(['invoiceitems' => function($query){

            $query->select('tax_rate');
            $query->groupBy('tax_rate');
    
    }]);  
      
     $invlist=$q->paginate(50);

In Result, Invoice table records returned but invoice items empty



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire