PHPackages                             centrex/laravel-addresses - 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. centrex/laravel-addresses

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

centrex/laravel-addresses
=========================

Manage address in laravel

v1.2.3(9mo ago)02.5k[4 PRs](https://github.com/centrex/laravel-addresses/pulls)MITPHPPHP ^8.2|^8.3|^8.4CI passing

Since Nov 15Pushed 1mo agoCompare

[ Source](https://github.com/centrex/laravel-addresses)[ Packagist](https://packagist.org/packages/centrex/laravel-addresses)[ Docs](https://github.com/centrex/laravel-addresses)[ RSS](/packages/centrex-laravel-addresses/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (16)Versions (15)Used By (0)

Manage addresses in Laravel
===========================

[](#manage-addresses-in-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/6c4ff5abfe14325cdc90a86ac8529e28ec8747876fbcbd5f74a49f1d2ae4eeda/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f63656e747265782f6c61726176656c2d6164647265737365732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/centrex/laravel-addresses)[![GitHub Tests Action Status](https://camo.githubusercontent.com/bf4e85ac0b9e8d9d3ba98a4daeed8ddc32efb92466b850ab679e04ace49ff553/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f63656e747265782f6c61726176656c2d6164647265737365732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/centrex/laravel-addresses/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/039c8e0aee6f961e62747e520aa2bce575c0219b231e3620794509e558541bfc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f63656e747265782f6c61726176656c2d6164647265737365732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/centrex/laravel-addresses/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/e5f35229f31977e0c001d5b116824753238eb3e2a603259ad01e727abbcea07a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f63656e747265782f6c61726176656c2d6164647265737365733f7374796c653d666c61742d737175617265)](https://packagist.org/packages/centrex/laravel-addresses)

Polymorphic address management for any Eloquent model. Supports multiple addresses per model with flag-based retrieval (primary, billing, shipping) and country code validation against a seeded countries table.

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

[](#installation)

```
composer require centrex/laravel-addresses
php artisan vendor:publish --tag="laravel-addresses-migrations"
php artisan migrate
php artisan db:seed --class="Centrex\Addresses\Database\Seeders\CountrySeeder"
```

Usage
-----

[](#usage)

### 1. Add the trait to your model

[](#1-add-the-trait-to-your-model)

```
use Centrex\Addresses\Traits\HasAddresses;

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

### 2. Add an address

[](#2-add-an-address)

The `country` field must be a valid ISO 3166-1 alpha-2 code present in the seeded countries table.

```
$customer->addAddress([
    'country'    => 'BD',
    'city'       => 'Dhaka',
    'state'      => 'Dhaka Division',
    'zip'        => '1000',
    'street'     => '123 Main Street',
    'is_primary' => true,
    'is_billing' => true,
]);
```

### 3. Retrieve addresses

[](#3-retrieve-addresses)

```
// All addresses
$customer->addresses;

// Check if any addresses exist
$customer->hasAddresses();

// Get by flag (primary | billing | shipping)
$customer->getAddress('billing');    // returns flagged address or falls back
$customer->getAddress('shipping', strict: true);  // only flagged, no fallback

// Latest address (no flag filter)
$customer->getAddress();
```

### 4. Update and delete

[](#4-update-and-delete)

```
$address = $customer->addresses->first();

$customer->updateAddress($address, ['city' => 'Chittagong']);

$customer->deleteAddress($address);

// Remove all
$customer->flushAddresses();
```

### Deprecated helpers (use `getAddress()` instead)

[](#deprecated-helpers-use-getaddress-instead)

```
$customer->getPrimaryAddress();
$customer->getBillingAddress();
$customer->getShippingAddress();
```

Testing
-------

[](#testing)

```
composer test        # full suite
composer test:unit   # pest only
composer test:types  # phpstan
composer lint        # pint
```

Changelog
---------

[](#changelog)

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

Credits
-------

[](#credits)

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

License
-------

[](#license)

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

###  Health Score

45

—

FairBetter than 92% of packages

Maintenance76

Regular maintenance activity

Popularity17

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 95.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

Every ~67 days

Recently: every ~41 days

Total

10

Last Release

298d ago

PHP version history (3 changes)v1.0.0PHP ^8.0|^8.1

v1.0.3PHP ^8.1|^8.2

v1.1.0PHP ^8.2|^8.3|^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/3b62fd49922fd1bf7d55b94cc82ebc9f359af7f343b246a7e3a2642779c0b4e7?d=identicon)[rochi88](/maintainers/rochi88)

---

Top Contributors

[![rochi88](https://avatars.githubusercontent.com/u/29769944?v=4)](https://github.com/rochi88 "rochi88 (43 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")

---

Tags

laravelcentrexlaravel-addresses

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/centrex-laravel-addresses/health.svg)

```
[![Health](https://phpackages.com/badges/centrex-laravel-addresses/health.svg)](https://phpackages.com/packages/centrex-laravel-addresses)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[laracraft-tech/laravel-useful-additions

A collection of useful Laravel additions!

58109.4k](/packages/laracraft-tech-laravel-useful-additions)[glhd/special

1929.4k](/packages/glhd-special)[bjuppa/laravel-blog

Add blog functionality to your Laravel project

483.3k2](/packages/bjuppa-laravel-blog)

PHPackages © 2026

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