aboleon/metaframework-google-places

Google Places address autocomplete component for Laravel

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/aboleon/metaframework-google-places

1.2.0 2026-01-28 15:25 UTC

This package is auto-updated.

Last update: 2026-01-28 16:29:58 UTC


README

Tests codecov Latest Version on Packagist Total Downloads PHP Version License

Google Places address autocomplete component for Laravel

Requirements

  • PHP ^8.3
  • Laravel ^11.0 | ^12.0
  • MetaFramework Inputable

Installation

composer require aboleon/metaframework-google-places

Publish assets/config/translations:

php artisan vendor:publish --tag=mfw-google-places-config
php artisan vendor:publish --tag=mfw-google-places-translations
php artisan vendor:publish --tag=mfw-google-places-assets

Configuration

config/mfw-google-places.php:

return [
    'google' => [
        'places_api_key' => env('MFW_GOOGLE_PLACES_KEY', ''),
    ],
    'countries_resolver' => null,
];

Resolver usage:

  • Set countries_resolver to a class that implements getCountryNameByCode($code) (and optional locale-aware getCountryNameByCodeAndLocale).
  • Example: MetaFramework\GooglePlaces\Accessors\Country::class to resolve country names from ISO-2 codes and locale files.

Usage

<x-mfw-google-places::form
    :model="$address"
    field="address"
    label="Address"
    :params="['required' => ['route', 'postal_code', 'locality']]"
    :hidden="['administrative_area_level_2']"
    :showCoords="true"
/>

To fully customize, publish the component and use the native Blade tag:

<x-google-places />

Artisan Commands

php artisan mfw-google-places:make-geo-model
php artisan mfw-google-places:make-geo-for-model {model?}
php artisan mfw-google-places:publish-component [--force]
php artisan mfw-google-places:publish-request [--force]
  • mfw-google-places:make-geo-model generates a new Geo model and migration with all Google Places fields.
  • mfw-google-places:make-geo-for-model adds a Google Places Geo relation and migration to an existing model (optionally provide the model class).
  • mfw-google-places:publish-component publishes app/View/Components/GooglePlaces.php and resources/views/components/google-places.blade.php for customization (use --force to overwrite).
  • mfw-google-places:publish-request publishes a GooglePlacesRequest to app/Http/Requests for customization (use --force to overwrite).

Validation example:

use MetaFramework\GooglePlaces\Validation\GoogleAddressValidation;

$rules = (new GoogleAddressValidation())
    ->setPrefix('address')
    ->setRequiredFields(['route', 'postal_code', 'locality'])
    ->rules();

Customize the published request:

php artisan mfw-google-places:publish-request
// app/Http/Requests/GooglePlacesRequest.php
public function rules(): array
{
    return (new GoogleAddressValidation())
        ->setPrefix('address')
        ->setRequiredFields(['route', 'postal_code', 'locality'])
        ->rules();
}