Make table data selectable based on condition

I want to make my table data selectable if its status == 1 is there any way to do that? My goal here is that I wanted to create a custom bulk action which they can borrow the available item.
public function table(Table $table): Table
{
return $table
->heading('Inventories')
->emptyStateHeading('No inventories yet')
->selectable() // Only selectable if status is 'Available'
->columns([
TextColumn::make('serial_number')
->label('Serial Number')
->sortable()
->searchable(),
TextColumn::make('status')
->label('Status')
->sortable()
->badge()
->color(fn ($state) => match ($state) {
0 => 'danger', // for 'Unavailable'
1 => 'success', // for 'Available'
})
->formatStateUsing(fn ($state) => $state ? 'Available' : 'Unavailable')
->searchable(),
TextColumn::make('created_at')
->sortable()
->dateTime('F j h:i A')
->searchable()
])
->filters([
// Add table filters if necessary
])
->actions([
// Add table actions if necessary
])
->bulkActions([
// Add bulk actions if necessary
]);
}
public function table(Table $table): Table
{
return $table
->heading('Inventories')
->emptyStateHeading('No inventories yet')
->selectable() // Only selectable if status is 'Available'
->columns([
TextColumn::make('serial_number')
->label('Serial Number')
->sortable()
->searchable(),
TextColumn::make('status')
->label('Status')
->sortable()
->badge()
->color(fn ($state) => match ($state) {
0 => 'danger', // for 'Unavailable'
1 => 'success', // for 'Available'
})
->formatStateUsing(fn ($state) => $state ? 'Available' : 'Unavailable')
->searchable(),
TextColumn::make('created_at')
->sortable()
->dateTime('F j h:i A')
->searchable()
])
->filters([
// Add table filters if necessary
])
->actions([
// Add table actions if necessary
])
->bulkActions([
// Add bulk actions if necessary
]);
}
TIA ❤️
No description
2 Replies
Chrysippus
ChrysippusOP5mo ago
It worked. Niceeee, thankyouuu!
Want results from more Discord servers?
Add your server