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

Abandoned → [lecturize/laravel-addresses](/?search=lecturize%2Flaravel-addresses)Library[Utility &amp; Helpers](/categories/utility)

vendocrat/laravel-addresses
===========================

Simple address and contact management for Laravel.

v1.0.1(5y ago)20141745[3 issues](https://github.com/AlexanderPoellmann/laravel-addresses/issues)[2 PRs](https://github.com/AlexanderPoellmann/laravel-addresses/pulls)MITPHPPHP ^7.3|^8.0

Since Sep 22Pushed 1y ago5 watchersCompare

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

READMEChangelog (4)Dependencies (8)Versions (8)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/0142706a63a8b5658edf9afa0689b50b7d9e7ef625c0a821bd9659dbf75cf60b/68747470733a2f2f706f7365722e707567782e6f72672f6c6563747572697a652f6c61726176656c2d6164647265737365732f762f737461626c65)](https://packagist.org/packages/lecturize/laravel-addresses)[![Total Downloads](https://camo.githubusercontent.com/28ecc73a1d66921606adb047f16cd9e4ca9fa3f1c621b3d680b31d973b4a7a8d/68747470733a2f2f706f7365722e707567782e6f72672f6c6563747572697a652f6c61726176656c2d6164647265737365732f646f776e6c6f616473)](https://packagist.org/packages/lecturize/laravel-addresses)[![License](https://camo.githubusercontent.com/0df0da186e9efb74609f7b1387253ecfec9218861fde3076a260681ba31cbfb9/68747470733a2f2f706f7365722e707567782e6f72672f6c6563747572697a652f6c61726176656c2d6164647265737365732f6c6963656e7365)](https://packagist.org/packages/lecturize/laravel-addresses)

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

[](#laravel-addresses)

Simple address and contact management for Laravel with automatical geocoding to add longitude and latitude.

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

[](#installation)

Require the package from your `composer.json` file

```
"require": {
	"lecturize/laravel-addresses": "^1.1"
}
```

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

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

[](#configuration--migration)

```
$ php artisan vendor:publish --provider="Lecturize\Addresses\AddressesServiceProvider"
```

This will publish the config file to `config/lecturize.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:

```
$address = config('lecturize.addresses.model', \Lecturize\Addresses\Models\Address::class)::find(1);
$contacts = $address->contacts;

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

```
$contact = config('lecturize.contacts.model', \Lecturize\Addresses\Models\Contact::class)::find(1)
                  ->contacts()
                  ->first();
```

```
$contact = config('lecturize.contacts.model', \Lecturize\Addresses\Models\Contact::class)::find(1);

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

##### Geocoding

[](#geocoding)

The address model provides a method `geocode()` which will try to fetch longitude and latitude through the Google Maps API. Please make sure to add your key within the services config file at `services.google.maps.key`. If you set the option `lecturize.addresses.geocode` to `true`, the package will automatically fire the `geocode()` method whenever an addresses model is saved (precisely we hook into the `saving` event).

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.
- \[2023-02-21\] **v1.2** Laravel 10 support.
- \[2023-09-21\] **v1.3** Support custom models for addresses and contacts, thanks to @bfiessinger. The geocoding feature now requires a Google Maps key, see 'Geocoding' above. Also, @bfiessinger has added fallback support for flags, see pull request #40 for further info.
- \[in-progress\] **v1.4** Added additional contact fields to the addresses table, to allow for easier standalone usage (without the contacts model). This is intended to reduce the complexity of relationships and queries, that before were necessary e.g. to generate a shipping label from address and contact.

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

43

—

FairBetter than 91% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 94.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 ~338 days

Recently: every ~507 days

Total

7

Last Release

1855d ago

Major Versions

v0.1.1 → v1.0.02021-02-02

PHP version history (4 changes)v0.0.1PHP &gt;=5.5.9

v0.1.0PHP &gt;=5.6.4|^7.0

v1.0.0PHP ^7.2.5|^8.0

v1.0.1PHP ^7.3|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/d780bcb538e8dfa5311d2d1bd17bad79e8b9b36e4e9eb4db980ef33c3a22b366?d=identicon)[AlexanderPoellmann](/maintainers/AlexanderPoellmann)

---

Top Contributors

[![AlexanderPoellmann](https://avatars.githubusercontent.com/u/6631793?v=4)](https://github.com/AlexanderPoellmann "AlexanderPoellmann (151 commits)")[![bfiessinger](https://avatars.githubusercontent.com/u/41627893?v=4)](https://github.com/bfiessinger "bfiessinger (8 commits)")[![jonerickson](https://avatars.githubusercontent.com/u/3356740?v=4)](https://github.com/jonerickson "jonerickson (1 commits)")

---

Tags

laravellaravel-addresseslaraveladdressescontactslecturize

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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