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

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

adiazm/laravel-addresses
========================

Simple address and contact management for Laravel.

v1.2.3(2y ago)010MITPHPPHP ^8.0

Since Sep 1Pushed 2y agoCompare

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

READMEChangelog (6)Dependencies (7)Versions (7)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/ca9dd8258e68fecb71285d3e07214c5f52137e7afe8baf70a66c28ddfdf61ddc/68747470733a2f2f706f7365722e707567782e6f72672f616469617a6d2f6c61726176656c2d6164647265737365732f762f737461626c65)](https://packagist.org/packages/adiazm/laravel-addresses)[![Total Downloads](https://camo.githubusercontent.com/c741b4dc8c3494e64800d573b290870c631f6f1c7f50129718c1e65001468fc4/68747470733a2f2f706f7365722e707567782e6f72672f616469617a6d2f6c61726176656c2d6164647265737365732f646f776e6c6f616473)](https://packagist.org/packages/adiazm/laravel-addresses)[![License](https://camo.githubusercontent.com/c4cecdc0f091593a75925e00467c5fddeda2db50989be9095c2372407f6268de/68747470733a2f2f706f7365722e707567782e6f72672f616469617a6d2f6c61726176656c2d6164647265737365732f6c6963656e7365)](https://packagist.org/packages/adiazm/laravel-addresses)

Laravel Addresses
=================

[](#laravel-addresses)

Simple address and contact management for Laravel with automatical geocoding to add longitude and latitude. Uses the famous [Countries](https://github.com/webpatser/laravel-countries) package by Webpatser.

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

[](#installation)

Require the package from your `composer.json` file

```
"require": {
	"adiazm/laravel-addresses": "^1.2"
}
```

and run `composer update` or both in one with `composer require adiazm/laravel-addresses`.

Configuration &amp; Migration
-----------------------------

[](#configuration--migration)

```
php artisan vendor:publish --provider="Admsys\Countries\CountriesServiceProvider"
php artisan vendor:publish --provider="Adiazm\Addresses\AddressesServiceProvider"
```

This will publish a `config/countries.php`, a `config/address-config.php` and some migration files, that you'll have to run:

```
php artisan countries:migration
php artisan migrate
```

For migrations to be properly published ensure that you have added the directory `database/migrations` to the classmap in your projects `composer.json`.

Check out [Webpatser\\Countries](https://github.com/webpatser/laravel-countries) readme to see how to seed their countries data to your database.

Usage
-----

[](#usage)

First, add our `HasAddresses` trait to your model.

```

```

##### Add an Address to a Model

[](#add-an-address-to-a-model)

```
$post = Post::find(1);
$post->addAddress([
    'street'     => '123 Example Drive',
    'city'       => 'Vienna',
    'post_code'  => '1110',
    'country'    => 'AT', // ISO-3166-2 or ISO-3166-3 country code
    'is_primary' => true, // optional flag
]);
```

Alternativly you could do...

```
$address = [
    'street'     => '123 Example Drive',
    'city'       => 'Vienna',
    'post_code'  => '1110',
    'country'    => 'AT', // ISO-3166-2 or ISO-3166-3 country code
    'is_primary' => true, // optional flag
];
$post->addAddress($address);
```

Available attributes are `street`, `street_extra`, `city`, `post_code`, `state`, `country`, `state`, `notes` (for internal use). You can also use custom flags like `is_primary`, `is_billing` &amp; `is_shipping`. Optionally you could also pass `lng` and `lat`, in case you deactivated the included geocoding functionality and want to add them yourself.

##### Check if Model has Addresses

[](#check-if-model-has-addresses)

```
if ($post->hasAddresses()) {
    // Do something
}
```

##### Get all Addresses for a Model

[](#get-all-addresses-for-a-model)

```
$addresses = $post->addresses()->get();
```

##### Get primary/billing/shipping Addresses

[](#get-primarybillingshipping-addresses)

```
$address = $post->getPrimaryAddress();
$address = $post->getBillingAddress();
$address = $post->getShippingAddress();
```

##### Update an Address for a Model

[](#update-an-address-for-a-model)

```
$address = $post->addresses()->first(); // fetch the address

$post->updateAddress($address, $new_attributes);
```

##### Delete an Address from a Model

[](#delete-an-address-from-a-model)

```
$address = $post->addresses()->first(); // fetch the address

$post->deleteAddress($address); // delete by passing it as argument
```

##### Delete all Addresses from a Model

[](#delete-all-addresses-from-a-model)

```
$post->flushAddresses();
```

Contacts
--------

[](#contacts)

First, add our `HasContacts` trait to your model.

```

```

##### Add a Contact to a Model

[](#add-a-contact-to-a-model)

```
$post = Team::find(1);
$post->addContact([
    'first_name' => 'Alex',
    'website'    => 'https://twitter.com/AMPoellmann',
    'is_primary' => true, // optional flag
]);
```

Relate Addresses with Contacts
------------------------------

[](#relate-addresses-with-contacts)

Above all, `addresses` and `contacts` can be connected with an optional One To Many relationship. Like so you could assign multiple contacts to an address and retrieve them like so:

```
use Adiazm\Addresses\Models\Address;

$address = Address::find(1);
$contacts = $address->contacts;

foreach ($contacts as $contact) {
    //
}
```

```
use Adiazm\Addresses\Models\Address;

$contact = Address::find(1)
                  ->contacts()
                  ->first();
```

```
use Adiazm\Addresses\Models\Contact;

$contact = Contact::find(1);

return $contact->address->getHtml();
```

Changelog
---------

[](#changelog)

- \[2021-02-02\] **v1.0** The `geocode` configuration option now defaults to `false`.
- \[2022-05-16\] **v1.1** Updated dependencies to PHP 8 and Laravel 8/9 - for older versions please refer to v1.0.

License
-------

[](#license)

Licensed under [MIT license](http://opensource.org/licenses/MIT).

Author
------

[](#author)

**Handcrafted with love by [Alexander Manfred Poellmann](https://twitter.com/AMPoellmann) in Vienna &amp; Rome.**

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 89.4% 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 ~0 days

Total

6

Last Release

984d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/598dc01eeeff08109f40c0eec3d4309d41c5aedbf18fbe2551423e30000662ec?d=identicon)[adiazm](/maintainers/adiazm)

---

Top Contributors

[![AlexanderPoellmann](https://avatars.githubusercontent.com/u/6631793?v=4)](https://github.com/AlexanderPoellmann "AlexanderPoellmann (118 commits)")[![adiazm](https://avatars.githubusercontent.com/u/13708873?v=4)](https://github.com/adiazm "adiazm (14 commits)")

---

Tags

laraveladdressescontacts

###  Code Quality

TestsPHPUnit

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/adiazm-laravel-addresses/health.svg)](https://phpackages.com/packages/adiazm-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)[lecturize/laravel-addresses

Simple address and contact management for Laravel.

20164.1k](/packages/lecturize-laravel-addresses)[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)
