RodolfoStein
Changing the style of a TextInput component dynamically
In my last job, I need to import a spreadsheet and compare the data from spreadsheet with my database.
I want that when I open that imported line from spreadsheet, I can change the fields that are differents for better visualization.
I already have it working, but I don´t know if I am in the best approach to solve the problem.
I run the comparisons phase and populate a json column with the differences...
And in every field I do this:
Forms\Components\TextInput::make('cargo')
->label('Cargo')
->hint(function (Closure $get) { $difs = $get('diferencas'); return Arr::has($difs, 'cargo.nome') ? $difs['cargo.nome'] : ''; })
->extraInputAttributes(function (Closure $get) { $difs = $get('diferencas'); if ( Arr::has($difs, 'cargo.nome') ) { return ['class' => 'ring-danger-500 ring-2']; } else {return [];} }, true)
->hintColor('danger')
->maxLength(255),
Is there a way to rewrite this in a more optimized way ?
1 replies
Code working in filament v2.16.52 and broken when I update today
Hello guys,
I was using filament v2.16.52 and this code in a widget is working well.
protected function getTableQuery(): Builder
{
return AvAnsweredForm::selectRaw(" MIN(id) as id, DATE_FORMAT(realized_date, '%Y-%m') AS year_and_month,
SUM((CASE WHEN answer_type = 'A' THEN 1 ELSE 0 END)) AS auto,
SUM((CASE WHEN answer_type = 'B' THEN 1 ELSE 0 END)) AS boss,
SUM((CASE WHEN answer_type = 'S' THEN 1 ELSE 0 END)) AS sub")
->groupBy('year_and_month')
->orderBy('year_and_month', 'DESC');
}
protected function getTableColumns(): array
{
return [
Tables\Columns\TextColumn::make('year_and_month')
->label('Ano - Mês'),
Tables\Columns\TextColumn::make('auto')
->label('Auto'),
Tables\Columns\TextColumn::make('boss')
->label('Chefia'),
Tables\Columns\TextColumn::make('sub')
->label('Subcomissão'),
];
}
today, I try to update and I am receiveing a SQL error saying the column year_and_month was not found.
any suggestions about my error ?
12 replies