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