getting parent relationship in form

I have a form that's creating a relationship, but I need to get a reference to the parent record and I can't seem to do it.

       Tab::make('config')->label('Config')->schema([
                        FieldSet::make()->relationship('detail')->schema([
                            Select::make('sms_type_id')
                           
                                ->options(SmsType::all()->pluck('name', 'id'))
                        
                                ->afterStateUpdated(function (?string $state, ?Model $record) {
                                    $record->sms_type_id = $state;
                                    // $record->location_id = $location->id; <---need to set this parent ID relationship.
                                    $record->save();
                                }),


I need to get a reference to the location for this particular page, which is the parent record of the above. I've tried using Get $get, I've tried referencing the Request since the ID I need is in the URL, but because it's just a livewire update call, the request doesn't help me.
Solution
Or maybe something like

Tab::make('config')
    ->label('Config')
    ->schema(function($record) {
        $parent = $record;
        return [
            FieldSet::make()
                ->relationship('detail')
                ->schema([
                    Select::make('sms_type_id')
                        ->options(SmsType::all()->pluck('name', 'id'))
                        ->afterStateUpdated(function (?string $state, ?Model $record) use ($parent) {
                            $record->sms_type_id = $state;
                            $record->location_id = $parent->id; <---need to set this parent ID relationship.
                            $record->save();
                        }),
                ])
        ];
    })
Was this page helpful?