select(DB::raw('COUNT(owner_id) AS count')) ->whereNotNull('owner_id') ->whereNotNull('logistic_id') ->leftJoin('orders','order_packages.order_id','orders.id') ->leftJoin('owners','orders.owner_id','owners.id') ->selectRaw('owners.id owner_id,owners.name owner_name') ->leftJoin('logistics','orders.logistic_id','logistics.id') ->selectRaw('logistics.id logistic_id,logistics.name logistic_name'); $columnQueryRules=[ 'date_start' => ['alias' => 'created_at','startDate' => " 00:00:00"], 'date_end' => ['alias' => 'created_at','endDate' => " 23:59:59"], 'logistic_id' => ['multi' => ','], 'owner_id' => ['multi' => ','], ]; $query = $query->groupBy(['owners.id','logistics.id']); return app(QueryService::class)->query($params,$query,$columnQueryRules); } public function get(array $params){ return $this->conditionQuery($params)->get(); } }