© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
3 replies
Chrysippus

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 ❤️
Screenshot_2024-07-31_at_3.21.00_PM.png
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

reordering based on condition
FilamentFFilament / ❓┊help
3y ago
hide Tabs based on condition
FilamentFFilament / ❓┊help
3y ago
filter table data based on external API
FilamentFFilament / ❓┊help
3y ago
Table list edit query based on certain conditions
FilamentFFilament / ❓┊help
2y ago