Mina
filter query join is not working for me
i've also tried with relationship, and i didn't manage to get it to work:
Tables\Filters\Filter::make('least_money_made')->query(function (Builder $query) {
return $query->withCount('orderRelation')
->with(['orderRelation' => function ($query) {
$query->selectRaw('funnel_id, SUM(total_price) as total_money_made')
->groupBy('funnel_id');
}])
->get()
->sortBy(function ($funnel) {
return $funnel->orderRelation_count > 0 ? $funnel->orderRelation->sum('total_money_made') : PHP_INT_MAX;
})
->first();
}),
8 replies