For now we can bind field one to one using fromValue() but is there any way to tell that if street_address is not empty use that value otherwise use route field from withValues array?
I have below implementation:
* Get the address fields for the resource.
*
* @return \Illuminate\Http\Resources\MergeValue
*/
protected function addressFields()
{
return $this->merge([
GoogleAutocomplete::make('Search Address To Auto-Fill Data Below', 'address')->withValues([
'street_number',
'route',
'locality',
'administrative_area_level_1',
'postal_code',
'country',
'latitude',
'longitude'
])->hideFromIndex()->hideFromDetail(),
AddressMetadata::make(__('Building Number'), 'building_number')->fromValue('street_number')->hideFromIndex(),
AddressMetadata::make(__('Street'), 'street')->fromValue('route')->hideFromIndex(),
AddressMetadata::make(__('City'), 'city')->fromValue('locality')->hideFromIndex()->rules('required'),
AddressMetadata::make(__('State'), 'state')->fromValue('administrative_area_level_1')->hideFromIndex(),
AddressMetadata::make(__('Zip Code'), 'zip_code')->fromValue('postal_code')->hideFromIndex(),
AddressMetadata::make('hidden_country', 'hidden_country')->fromValue('country')->invisible()->hideFromIndex()->hideFromDetail(),
BelongsTo::make('Country', 'country', 'App\Nova\Country')->display(function($m) {
return $m->name;
})->hideFromIndex()->rules('required'),
AddressMetadata::make('Latitude', 'latitude')->fromValue('latitude')->hideFromIndex(),
AddressMetadata::make('Longitude', 'longitude')->fromValue('longitude')->hideFromIndex(),
]);
}
For now we can bind field one to one using
fromValue()
but is there any way to tell that ifstreet_address
is not empty use that value otherwise useroute
field fromwithValues
array?I have below implementation: