PHPackages                             a21ns1g4ts/filament-br-address - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. a21ns1g4ts/filament-br-address

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

a21ns1g4ts/filament-br-address
==============================

Brazilian address fields for Filament

v0.1.0(2mo ago)0119[2 PRs](https://github.com/a21ns1g4ts/filament-br-address/pulls)MITPHPPHP ^8.3CI passing

Since May 24Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/a21ns1g4ts/filament-br-address)[ Packagist](https://packagist.org/packages/a21ns1g4ts/filament-br-address)[ Docs](https://github.com/a21ns1g4ts/filament-br-address)[ GitHub Sponsors](https://github.com/a21ns1g4ts)[ RSS](/packages/a21ns1g4ts-filament-br-address/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (1)Dependencies (17)Versions (5)Used By (0)

Filament BR Address
===================

[](#filament-br-address)

[![Latest Version on Packagist](https://camo.githubusercontent.com/6699ab8536251cbbb8770da9f27dd612e94fa0a76959e62364ddcbdcfd9030c9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6132316e7331673474732f66696c616d656e742d62722d616464726573732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/a21ns1g4ts/filament-br-address)[![GitHub Tests Action Status](https://camo.githubusercontent.com/000aa929b6de9adbeefd18895b102201b2869f435fa1d613d92ba11a03674e87/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6132316e7331673474732f66696c616d656e742d62722d616464726573732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/a21ns1g4ts/filament-br-address/actions?query=workflow%3Arun-tests+branch%3Amain)[![Coverage](https://camo.githubusercontent.com/0a41861b061eefca38f2be5212f9b42b373a2ca78469da086382012221e63a95/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6132316e7331673474732f66696c616d656e742d62722d616464726573732f6d61696e3f7374796c653d666c61742d737175617265)](https://codecov.io/gh/a21ns1g4ts/filament-br-address)[![Total Downloads](https://camo.githubusercontent.com/b02687bcca2723de1b47476c775364db252c86b2b44ae1fb783b5243867f2784/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6132316e7331673474732f66696c616d656e742d62722d616464726573732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/a21ns1g4ts/filament-br-address)

Brazilian address fields for Filament, with CEP lookup and an optional map field that ships with Mapbox and Google Maps support.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require a21ns1g4ts/filament-br-address
```

You can publish the config file with:

```
php artisan vendor:publish --tag="filament-br-address-config"
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="filament-br-address-migrations"
php artisan migrate
```

Configuration
-------------

[](#configuration)

Set your preferred map provider and credentials:

```
FILAMENT_BR_ADDRESS_MAP_PROVIDER=mapbox
MAPBOX_ACCESS_TOKEN=

# or
FILAMENT_BR_ADDRESS_MAP_PROVIDER=google
GOOGLE_MAPS_API_KEY=
```

The package config also controls CEP lookup and defaults:

```
return [
    'address_model' => \A21ns1g4ts\FilamentBrAddress\Models\Address::class,

    'cep' => [
        'base_url' => env('FILAMENT_BR_ADDRESS_CEP_BASE_URL', 'https://brasilapi.com.br/api'),
        'timeout' => env('FILAMENT_BR_ADDRESS_CEP_TIMEOUT', 10),
        'cache_ttl' => env('FILAMENT_BR_ADDRESS_CEP_CACHE_TTL', 86400),
    ],

    'maps' => [
        'default' => env('FILAMENT_BR_ADDRESS_MAP_PROVIDER', 'mapbox'),
        'height' => env('FILAMENT_BR_ADDRESS_MAP_HEIGHT', 400),
    ],
];
```

Usage
-----

[](#usage)

Add the trait to any model that owns addresses:

```
use A21ns1g4ts\FilamentBrAddress\Concerns\HasAddresses;

class Customer extends Model
{
    use HasAddresses;
}
```

Use the default Filament schema:

```
use A21ns1g4ts\FilamentBrAddress\Filament\Forms\AddressForm;
use A21ns1g4ts\FilamentBrAddress\Filament\Tables\AddressTable;

AddressForm::configure();
AddressForm::configure(mapProvider: 'google');
AddressForm::configure(withMap: false);

AddressTable::getDefaultColumns();
AddressTable::getDefaultFilters();
```

You can also use the facade:

```
use A21ns1g4ts\FilamentBrAddress\Facades\FilamentBrAddress;

FilamentBrAddress::form();
FilamentBrAddress::tableColumns();
FilamentBrAddress::tableFilters();
```

Components
----------

[](#components)

### `Address`

[](#address)

`A21ns1g4ts\FilamentBrAddress\Models\Address` is the default Eloquent model for the `addresses` table.

It includes:

- `addressable_id` and `addressable_type` morph fields.
- Brazilian address fields: `zip_code`, `street`, `number`, `neighborhood`, `city`, `state`, `ibge`, `country`.
- Map coordinates: `lat`, `lng`.
- Address classification: `type`, `is_default`, `complement`.
- Computed `location` array with `lat` and `lng`.
- Computed `full_address` string.
- CEP normalization before saving.
- Default-address guard so only one address per owner is marked as default.

### `HasAddresses`

[](#hasaddresses)

Use `A21ns1g4ts\FilamentBrAddress\Concerns\HasAddresses` on models that own addresses:

```
use A21ns1g4ts\FilamentBrAddress\Concerns\HasAddresses;

class Customer extends Model
{
    use HasAddresses;
}

$customer->addresses;
$customer->defaultAddress();
```

If you need a custom model, change `address_model` in the package config.

### `AddressType`

[](#addresstype)

`A21ns1g4ts\FilamentBrAddress\Enums\AddressType` provides the default Filament labels for:

- `home`
- `work`
- `billing`
- `shipping`

### `AddressForm`

[](#addressform)

`A21ns1g4ts\FilamentBrAddress\Filament\Forms\AddressForm` returns a ready-to-use Filament schema:

```
AddressForm::configure();
```

Available arguments:

```
AddressForm::configure(
    withMap: true,
    mapProvider: 'mapbox',
    mapAccessToken: 'your-mapbox-token',
    mapApiKey: null,
);
```

For Google Maps:

```
AddressForm::configure(
    mapProvider: 'google',
    mapApiKey: 'your-google-maps-key',
);
```

Without a map:

```
AddressForm::configure(withMap: false);
```

The form looks up Brazilian CEPs through BrasilAPI and fills `street`, `neighborhood`, `city`, `state`, `ibge`, and `country`. When the map is enabled, it dispatches geocoding updates to the map field.

### `AddressMap`

[](#addressmap)

`A21ns1g4ts\FilamentBrAddress\Forms\Components\AddressMap` is a standalone Filament field. It works with `lat` and `lng` fields in the same parent state path.

Mapbox example:

```
use A21ns1g4ts\FilamentBrAddress\Forms\Components\AddressMap;

AddressMap::make('location')
    ->provider('mapbox')
    ->accessToken('your-mapbox-token');
```

Google Maps example:

```
AddressMap::make('location')
    ->provider('google')
    ->apiKey('your-google-maps-key');
```

Other options:

```
AddressMap::make('location')
    ->height(480)
    ->draggable()
    ->showControls();
```

If you do not pass keys directly, the component reads from `config('filament-br-address.maps.*')`.

Custom JavaScript providers can be registered with:

```
window.filamentBrAddressMapProviders = window.filamentBrAddressMapProviders || {}

window.filamentBrAddressMapProviders.myProvider = (config, component) => ({
    async boot() {
        // Initialize your map provider here.
    },

    async geocodeAddress(address) {
        // Geocode and call component.updateCoordinates(lat, lng).
    },
})
```

Then use:

```
AddressMap::make('location')
    ->provider('myProvider');
```

### `AddressTable`

[](#addresstable)

`A21ns1g4ts\FilamentBrAddress\Filament\Tables\AddressTable` exposes table defaults:

```
AddressTable::getDefaultColumns();
AddressTable::getDefaultFilters();
```

The default columns include street, number, neighborhood, city, state, ZIP code, type, and a toggle for the default address.

### `CepService`

[](#cepservice)

`A21ns1g4ts\FilamentBrAddress\Services\CepService` performs CEP lookup against BrasilAPI by default:

```
app(\A21ns1g4ts\FilamentBrAddress\Services\CepService::class)->get('78000000');
```

The service caches results using Laravel cache. You can change the base URL, timeout, and TTL in the package config.

Testing
-------

[](#testing)

```
composer test
composer test-coverage
composer phpstan
composer format
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [a21ns1g4ts](https://github.com/a21ns1g4ts)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance91

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 52.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

61d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8ef934abfc0e93bb150f57a7a8826d29b04829e3e60d62358e87d42705d4be21?d=identicon)[a21ns1g4ts](/maintainers/a21ns1g4ts)

---

Top Contributors

[![a21ns1g4ts](https://avatars.githubusercontent.com/u/11599205?v=4)](https://github.com/a21ns1g4ts "a21ns1g4ts (10 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (7 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (2 commits)")

---

Tags

laravelfilamenta21ns1g4tsfilament-br-address

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/a21ns1g4ts-filament-br-address/health.svg)

```
[![Health](https://phpackages.com/badges/a21ns1g4ts-filament-br-address/health.svg)](https://phpackages.com/packages/a21ns1g4ts-filament-br-address)
```

###  Alternatives

[ysfkaya/filament-phone-input

A phone input component for Laravel Filament

3161.3M26](/packages/ysfkaya-filament-phone-input)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.8k](/packages/rawilk-profile-filament-plugin)[backstage/mails

View logged mails and events in a beautiful Filament UI.

16121.5k](/packages/backstage-mails)[stephenjude/filament-feature-flags

Filament implementation of feature flags and segmentation with Laravel Pennant.

123177.8k1](/packages/stephenjude-filament-feature-flags)[wsmallnews/filament-nestedset

Filament nestedset tree builder powered by kalnoy/nestedset with Filament v4 and v5 support

197.8k19](/packages/wsmallnews-filament-nestedset)[tapp/filament-form-builder

User facing form builder using Filament components

132.4k5](/packages/tapp-filament-form-builder)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
