l33tneko
Problem with rows that have null values
Table definition
public function table(Table $table): Table
{
return $table
->query((new Query())->get())
->filters([
(new Filters())->getStructureTrainerGroupFilter()
])
->columns([
Tables\Columns\TextColumn::make('user.full_name')->label('Фамилия, Имя, Отчество')->searchable(),
Tables\Columns\SelectColumn::make('kyudan.place')
->options(Kyudans::LIST)
->label('Стилевая квалификация')
->updateStateUsing(function (string $state, Sportsman $record): ?string {
$this->kyudans[$record->id]['number'] = $state;
return $state;
}),
Tables\Columns\TextInputColumn::make('kyudan.certificate_number')
->label('Номер сертификата')
])
->recordClasses(function (Sportsman $record) {
$isKyudanExists = $record->kyudan()->exists();
if ($isKyudanExists)
{
return 'bg-yellow-100';
}
return null;
});
}
public function table(Table $table): Table
{
return $table
->query((new Query())->get())
->filters([
(new Filters())->getStructureTrainerGroupFilter()
])
->columns([
Tables\Columns\TextColumn::make('user.full_name')->label('Фамилия, Имя, Отчество')->searchable(),
Tables\Columns\SelectColumn::make('kyudan.place')
->options(Kyudans::LIST)
->label('Стилевая квалификация')
->updateStateUsing(function (string $state, Sportsman $record): ?string {
$this->kyudans[$record->id]['number'] = $state;
return $state;
}),
Tables\Columns\TextInputColumn::make('kyudan.certificate_number')
->label('Номер сертификата')
])
->recordClasses(function (Sportsman $record) {
$isKyudanExists = $record->kyudan()->exists();
if ($isKyudanExists)
{
return 'bg-yellow-100';
}
return null;
});
}
3 replies
Refresh table in livewire component
View
<label class="label cursor-pointer w-fit">
<span class="label-text">Deleted sportsmen</span>
<input class="checkbox ml-4" type="checkbox" wire:model.live="deletedSportsmen">
</label>
<label class="label cursor-pointer w-fit">
<span class="label-text">Deleted sportsmen</span>
<input class="checkbox ml-4" type="checkbox" wire:model.live="deletedSportsmen">
</label>
6 replies
Refresh table in livewire component
Component
class Sportsmen extends Component implements HasTable, HasForms
{
use InteractsWithTable;
use InteractsWithForms;
public bool $deletedSportsmen = false;
public function table(Table $table): Table
{
return $table
->query(SportsmanQuery::make(active: !$this->deletedSportsmen)->execute())
->columns([/* Columns */])
}
}
class Sportsmen extends Component implements HasTable, HasForms
{
use InteractsWithTable;
use InteractsWithForms;
public bool $deletedSportsmen = false;
public function table(Table $table): Table
{
return $table
->query(SportsmanQuery::make(active: !$this->deletedSportsmen)->execute())
->columns([/* Columns */])
}
}
6 replies