SebboRR
SebboRR
FFilament
Created by SebboRR on 3/17/2024 in #❓┊help
How to GrpupBy and Sum in Widget Table.
I have widget table where I want sum some columns grouped by accoount_id and instrument_id I don't know how to sum values like number, provision ... ->sum('number') // Dont work I havean error: Filament\Tables\Table::query(): Argument #1 ($query) must be of type Illuminate\Database\Eloquent\Builder|Closure|null, int given, called in C:\laragon\www\inwestycje\app\Filament\Widgets\InstrumentsInAccouts.php on line 29
class InstrumentsInAccouts extends BaseWidget
{

protected int | string | array $columnSpan = 'full';

protected static ?int $sort = 2;

public static function getEloquentQuery(): Builder
{
return static::getModel()::query()->where('is_admin', 1);
}

public function table(Table $table): Table
{
return $table
->query(
TransactionResource::getEloquentQuery()
->groupBy('account_id', 'instrument_id')
->sum('number') // Dont work
)
->defaultSort('created_at', 'desc')
->columns([
TextColumn::make('date')->sortable(),

TextColumn::make('account.name')->sortable(),

TextColumn::make('number')
->alignRight(),
TextColumn::make('instrument.name'),

TextColumn::make('price')
->money('PLN', locale: 'pl')
->alignRight(),

TextColumn::make('provision')
->money('PLN', locale: 'pl')
->alignRight()
->summarize(Sum::make()),

TextColumn::make('number')
->alignRight(),
]);
}
}
}
class InstrumentsInAccouts extends BaseWidget
{

protected int | string | array $columnSpan = 'full';

protected static ?int $sort = 2;

public static function getEloquentQuery(): Builder
{
return static::getModel()::query()->where('is_admin', 1);
}

public function table(Table $table): Table
{
return $table
->query(
TransactionResource::getEloquentQuery()
->groupBy('account_id', 'instrument_id')
->sum('number') // Dont work
)
->defaultSort('created_at', 'desc')
->columns([
TextColumn::make('date')->sortable(),

TextColumn::make('account.name')->sortable(),

TextColumn::make('number')
->alignRight(),
TextColumn::make('instrument.name'),

TextColumn::make('price')
->money('PLN', locale: 'pl')
->alignRight(),

TextColumn::make('provision')
->money('PLN', locale: 'pl')
->alignRight()
->summarize(Sum::make()),

TextColumn::make('number')
->alignRight(),
]);
}
}
}
3 replies
FFilament
Created by SebboRR on 2/28/2024 in #❓┊help
How to set custom badge color based on color picker.
How to set custom badge color based on color picker or filament-tailwind-color-picker. Maybe I have to use: ViewColumn with custom view ?? How to setup this ?
9 replies
FFilament
Created by SebboRR on 2/22/2024 in #❓┊help
How to change background color of sidebar
I wont to change the background color of the sidebar I found this description: https://filamentphp.com/docs/3.x/support/style-customization but I don't know where to put this code until it worked. .fi-sidebar { @apply bg-gray-50 dark:bg-gray-950; }
5 replies
FFilament
Created by SebboRR on 2/20/2024 in #❓┊help
Many to Many (Polymorphic) in Table View
No description
5 replies