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
            ]);
    }



TIA ❤️
Screenshot_2024-07-31_at_3.21.00_PM.png
Was this page helpful?