I have 3 resources. - OfficeResource (Model: Office) - OfficeAddressResource (Model: OfficeAddress) - CountryResource (Model: Country)
I have a form on the OfficeResource with a select field. This select field searches the OfficeAddress table and allows for the selection of an address. The OfficeAddress model has a
hasone
hasone
relationship with the model Country.
Problem: On my OfficeResource form, I want to search by the address, city, and country.common_name in the address select form element. How would I accomplish this?
Here is the select element on the OfficeResource form:
Select::make('office_physical_address_id') ->label('Physical Address') ->relationship(name: 'physicalAddress', titleAttribute: 'street_address') ->getOptionLabelFromRecordUsing(fn(OfficeAddress $record) => $record->full_address) ->searchable(['street_address', 'city']) ->createOptionForm(OfficeAddressForm::getForm()) ->editOptionForm(OfficeAddressForm::getForm()) ->helperText('Click the + button to add a new address, or choose from the dropdown.') ->preload(),
Select::make('office_physical_address_id') ->label('Physical Address') ->relationship(name: 'physicalAddress', titleAttribute: 'street_address') ->getOptionLabelFromRecordUsing(fn(OfficeAddress $record) => $record->full_address) ->searchable(['street_address', 'city']) ->createOptionForm(OfficeAddressForm::getForm()) ->editOptionForm(OfficeAddressForm::getForm()) ->helperText('Click the + button to add a new address, or choose from the dropdown.') ->preload(),