Euu83
Euu83
FFilament
Created by Euu83 on 6/18/2024 in #❓┊help
Calculate summarize from others summarize
return $table
->columns([
Tables\Columns\TextColumn::make('name')
->label('Name'),
Tables\Columns\TextColumn::make('id')
->label('Id'),
Tables\Columns\TextColumn::make('bet')
->label('Bet')
->summarize([
Sum::make()->label('')
])
->money('EUR')
->color('success'),
Tables\Columns\TextColumn::make('win')
->label('Win')
->money('EUR')
->color('danger')
->summarize([
Sum::make()->label('')
]),
Tables\Columns\TextColumn::make('result')
->label('Result')
->money('EUR')
->color(function ($state) {
if($state > 0) {
return 'success';
}
return 'danger';
})
->summarize([
Sum::make()->label('')
]),
Tables\Columns\TextColumn::make('rtp')
->numeric(decimalPlaces: 2)
->formatStateUsing(function ($record) {
return number_format($record->rtp,2,'.').' %';
})
->summarize()->label(''))
->label('RTP')
->color('success'),
])
return $table
->columns([
Tables\Columns\TextColumn::make('name')
->label('Name'),
Tables\Columns\TextColumn::make('id')
->label('Id'),
Tables\Columns\TextColumn::make('bet')
->label('Bet')
->summarize([
Sum::make()->label('')
])
->money('EUR')
->color('success'),
Tables\Columns\TextColumn::make('win')
->label('Win')
->money('EUR')
->color('danger')
->summarize([
Sum::make()->label('')
]),
Tables\Columns\TextColumn::make('result')
->label('Result')
->money('EUR')
->color(function ($state) {
if($state > 0) {
return 'success';
}
return 'danger';
})
->summarize([
Sum::make()->label('')
]),
Tables\Columns\TextColumn::make('rtp')
->numeric(decimalPlaces: 2)
->formatStateUsing(function ($record) {
return number_format($record->rtp,2,'.').' %';
})
->summarize()->label(''))
->label('RTP')
->color('success'),
])
for rtp I want to calculate an average that depends on the summarize win and summarize bet but I don't know how to do it for the rtp summarize.
2 replies
FFilament
Created by Euu83 on 6/13/2024 in #❓┊help
Get item table, each element and add a new item
I need to get the data/rows to be displayed in a table component, traverse it and add a new row that is the result of the sum of values when traversing the data/rows. Is it possible?
12 replies
FFilament
Created by Euu83 on 6/10/2024 in #❓┊help
After applying a filter, I want to make a grouping to the resulting query but it does not do it.
groupByCurrency() is the second scope where I do the second grouping. When analyzing the resulting query it shows the where but not the grouping.
->filters([
Tables\Filters\Filter::make('month_year')
->form([
Forms\Components\Select::make('month')
->options([
'01' => 'January',
'02' => 'February',
'03' => 'March',
'04' => 'April',
'05' => 'May',
'06' => 'June',
'07' => 'July',
'08' => 'August',
'09' => 'September',
'10' => 'October',
'11' => 'November',
'12' => 'December',
])
->required()
->default(date('m')),
Forms\Components\Select::make('year')
->options($yearOptions)
->required()
->default(date('Y')),
])
->query(function ($query, array $data) {
if (isset($data['month']) && isset($data['year'])) {
$startDate = Carbon::create($data['year'], $data['month'], 1)->startOfMonth();
$endDate = Carbon::create($data['year'], $data['month'], 1)->endOfMonth();
$startDate = '2024-01-01';
$endDate = '2024-01-02';
$query->whereBetween('games_wagers_rolls.date',[$startDate,$endDate])->groupByCurrency();
}
})
])
->filters([
Tables\Filters\Filter::make('month_year')
->form([
Forms\Components\Select::make('month')
->options([
'01' => 'January',
'02' => 'February',
'03' => 'March',
'04' => 'April',
'05' => 'May',
'06' => 'June',
'07' => 'July',
'08' => 'August',
'09' => 'September',
'10' => 'October',
'11' => 'November',
'12' => 'December',
])
->required()
->default(date('m')),
Forms\Components\Select::make('year')
->options($yearOptions)
->required()
->default(date('Y')),
])
->query(function ($query, array $data) {
if (isset($data['month']) && isset($data['year'])) {
$startDate = Carbon::create($data['year'], $data['month'], 1)->startOfMonth();
$endDate = Carbon::create($data['year'], $data['month'], 1)->endOfMonth();
$startDate = '2024-01-01';
$endDate = '2024-01-02';
$query->whereBetween('games_wagers_rolls.date',[$startDate,$endDate])->groupByCurrency();
}
})
])
3 replies