Enable or Disable Toggle by default when first page load

Hi Everyone i have problem when i create custom function schema on my grid to show list based on checklists that i have

Here's the code, and i got trouble when i want to set by default the toggle is enable/active/on is everyone have any good approach to solve this problem ?

Grid::make('checklists')
                                        ->columns(2)
                                        ->schema(function ($record): array {
                                            $checklists = JobChecklist::where('job_report_checklist_id', $record->id)->get();
                                            $components = [];
                                            foreach ($checklists as $checklist) {

                                                $components[] = Toggle::make("checklist_{$checklist->id}_check")
                                                    ->label('Completed')
                                                    ->inline(false)
                                                    ->default(function () use ($checklist) {
                                                        return $checklist->check;
                                                    })
                                                    ->reactive()
                                                    ->afterStateUpdated(function ($state, callable $get) use ($checklist) {
                                                        $jobChecklist = JobChecklist::find($checklist->id);
                                                        $jobChecklist->update(['check' => $state]);
                                                    });
                                            }

                                            return $components;
                                        })
                                        ->columnSpanFull(),
WhatsApp_Image_2024-10-20_at_18.02.45.jpeg
Was this page helpful?