ToggleColumn - making conditionally invisible

Hi I have the following code snippet

                ToggleColumn::make('is_indexed')
                    ->label('Index?')
                    ->onColor('info')
                    ->beforeStateUpdated(function ($record, $state) {
                        
                        // Runs before the state is saved to the database.
                    })
                    ->afterStateUpdated(function ($record, $state) {
                        // Runs after the state is saved to the database.
                    })
                    ->visible(function ($record) {
                      dd($record->record_type);

                    })


In the
beforeStateUpdated
I can access $record - but within
visible
I am unable to (i.e. generates an error - "Attempt to read property "record_type" on null").

I don't understand why $record isn't universally available to me - but accepting that's the case, how would I access the current record within the
visible
method so that I can determine whether the toggle should be shown or not?

thanks for your help!
j
Was this page helpful?