Euu83
table group only results in querying all records
Hello, you can use the methods
query
or modifyQueryUsing
of the table for example call a the scope of model that you load in the resource
public static function table(Table $table): Table
{
return $table->modifyQueryUsing(fn (Builder $query) => $query->balanceDays())
->query(function () {
$query->where('active','=',true)
})
->columns([
Tables\Columns\TextColumn::make('user_id_balance')
->alignRight()
->label('User')
14 replies
Table Builder with dynamic array source?
I'm in the same situation and I think I'm going to use this plugin https://filamentphp.com/plugins/eightynine-reports, let's see how it goes.
10 replies
Get item table, each element and add a new item
When you use summaries, what you do is apply a sum to the base query. If you analyze for example the requests with telescope you can see that it will make a query such as select * from games and if you apply a summaries to prize you also execute select sum(prize) from games.
12 replies
After applying a filter, I want to make a grouping to the resulting query but it does not do it.
I have been able to solve it by using the getTableQuery() method from the page/index
protected function getTableQuery(): Builder
{
$query = GamesWagersRoll::query()->getRTP();
if(isset($this->tableFilters['month_year'])) {
$data = $this->tableFilters['month_year'];
$startDate = Carbon::create($data['year'], $data['month'], 1)->startOfMonth();
$endDate = Carbon::create($data['year'], $data['month'], 1)->endOfMonth();
$query->whereBetween('games_wagers_rolls.date',[$startDate,$endDate]);
$subquery = $query->whereBetween('games_wagers_rolls.date', [$startDate, $endDate]);
$query = GamesWagersRoll::fromSub($subquery,'sub_orders')
->selectRaw('sub_orders.id,SUM(players) as players')
->groupBy('sub_orders.id')
->orderBy('sub_orders.id');
}
return $query;
}
3 replies