hnassr/nova-places
A Laravel Nova field that adds Google Places autocomplete to your forms. Users search and select addresses or locations as they type, and the chosen place details are saved. Just add your Google Maps API key to get fast, accurate location input in Nova resources.
composer require hnassr/nova-places. The service provider is auto-discovered; if assets are not served by Nova's asset pipeline, publish them with php artisan vendor:publish --provider="Hnassr\NovaPlaces\FieldServiceProvider" (check the provider name in src/ for this repo).composer.json before installing. The last release (May 2020) targets Nova 2/3-era APIs; it will not install against Nova 4+ without patching composer.json and porting the Vue component.config/nova-places.php) or env vars like ALGOLIA_PLACES_APP_ID / ALGOLIA_PLACES_API_KEY, and set them before touching any resource.src/NovaPlaces.php for the fluent setters/meta it exposes, and resources/js/components/Field.vue (or dist/js/field.js) to see exactly how the places() instance is created, which event sets the field value, and whether it writes only the formatted string.use Hnassr\NovaPlaces\NovaPlaces;
public function fields(Request $request)
{
return [
ID::make()->sortable(),
NovaPlaces::make('Address'),
];
}
withMeta()) to restrict by country, place type, and language so results match your data model — e.g. cities only, one country, site locale. This is the most common day-to-day configuration and belongs in a small helper or a base resource method rather than copy-pasted on every field.->onlyOnForms() (or ->hideFromIndex()) and render the stored string with a plain Text field on detail/index views. This also avoids shipping the Algolia JS to index pages.value; the field typically persists that single string. If your schema stores street, city, postal_code, country separately, either:
->fillUsing(fn ($request, $model, $attribute, $requestAttribute) => ...) to parse/split the submitted value, orNovaPlaces as a "search assist" field mapped to a virtual attribute and hydrate the real columns in the model's setter/observer.latlng; the default field usually does not store it. If you need geo data, add hidden latitude/longitude fields and either extend the Vue component's change handler to populate them, or geocode once server-side on save (do not geocode on every read).->rules('required', 'string', 'max:255') with a prepareForValidation/fillUsing normalization step so manually typed values (users can ignore suggestions) match the same shape as autocompleted ones.AddressField::make()) that applies your standard countries/type/language meta, so a future swap to another provider is a one-file change..ap-dropdown/.ap-suggestion in places.js) before clicking — race conditions here are the usual source of flaky tests.dist/js/field.js is what actually ships. If you edit resources/js you must rebuild (npm install && npm run dev inside the package) and re-publish/copy the dist output; editing the source alone changes nothing.config('nova-places...') returning null on cached config is common — run php artisan config:clear).countries but leaving the browser language/language option unset produces odd formatted strings; set both consistently or your stored values will vary by user.Field.vue what gets emitted on change before designing your schema around it.withMeta() for provider options, fillUsing() for persistence logic, and resolveUsing() for display are the three hooks you will actually need when adapting this to a live geocoder.How can I help you explore Laravel packages today?