Toggle Column Prevent Action

Hello,

I have an issue cannot seem to figure out where to place my check on record if it has all requried fields - only than it can be activated.

I tried beforeStateUpdated but it throws warning but still proceeds to update that record? Any idea how to prevent it?

Tables\Columns\ToggleColumn::make('active')
                    ->disabled(function (Project $record) {
                        return !$record->hasAllRequiredFields();
                    })
                    ->afterStateUpdated(function(){
                        Cache::forget(CacheManager::makeCacheToken("active_projects"));

                        Notification::make()
                            ->success()
                            ->title(__("Project Status Updated"))
                            ->send();
                    }),
Was this page helpful?