Skip to content

sonover/address

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sonover Address Module

Sonover Address is a Concord module that allows you to store addresses for an entity. Being a Concord module it is intended to be used by Laravel Applications.

Installation

  1. composer require sonover/address
  2. If concord hasn't been installed yet, install it
  3. Edit config/concord.php and add the address module:
return [
    'modules' => [
        Sonover\Address\Providers\ModuleServiceProvider::class
    ]
];

After this, address should be listed among the concrd modules:

php artisan concord:modules -a

+----+-----------------------+--------+---------+------------------+-----------------+
| #  | Name                  | Kind   | Version | Id               | Namespace       |
+----+-----------------------+--------+---------+------------------+-----------------+
| 1. | Sonover Address Module | Module | 0.2.0   | sonover.address | Sonover\Address |
+----+-----------------------+--------+---------+------------------+-----------------+

Usuage

class Contact extends Model {
    use Addressable;
}

Add an Address

$contact->addAddress([
    'address' => 'Example',
    'city' => 'Example City',
    'province' => 'St. George',
    'country' => 'GD',
    'postalcode' => 'GD-142'
], 'shipping');

Get all shipping addresses

$contact->shippingAddress

The following types are supported out of the box: billing, business, contract, mailing, pickup, residential and shipping

If you want to extend this list for your application refer to Extending Enums in Concord's documentation.

You can grab any address by the type $contact->{type}Address

Remove Address

$contact->removeAddress($address)