| Package Data | |
|---|---|
| Maintainer Username: | dondraper_ | 
| Maintainer Contact: | rtconner@gmail.com (Robert Conner) | 
| Package Create Date: | 2015-05-23 | 
| Package Last Update: | 2015-05-23 | 
| Language: | PHP | 
| License: | MIT | 
| Last Refreshed: | 2025-11-02 15:19:57 | 
| Package Statistics | |
|---|---|
| Total Downloads: | 51 | 
| Monthly Downloads: | 0 | 
| Daily Downloads: | 0 | 
| Total Stars: | 1 | 
| Total Watchers: | 0 | 
| Total Forks: | 1 | 
| Total Open Issues: | 0 | 
Link a list of addresses to a user. Allows to flag address as primary, billing, or shipping. Users have many addresses, but only one primary or shipping or billing.
Sample views and controller are included. I don't recoment you use them directly, butjust use them as example code to copy and paste.
"require": {
    "rtconner/laravel-addresses": "dev-master"
}
php artisan migrate --package=rtconner/laravel-addresses
'providers' => array(
	'Conner\Addresses\AddressesServiceProvider',
),
\Addresses::getAll($user->id); // get all users
if(Addresses::getValidator()->fails()) { } // validate before saving
$address = Addresses::createAddress(\Input::all()); // this does not auto-validate
$address = Addresses::updateAddress(\Input::all()); // this does not auto-validate
Addresses::deleteAddress($address);
Addresses::setPrimary($address); // set address as primary (and unset the others)
Addresses::getPrimary();    
Addresses::getShipping($userId);    
Addresses::getBilling();    
@include('addresses::fields') <!-- bootstrap fields with no form tags -->
@foreach($addresses as $address)
	@include('addresses::view', compact('separator'=>'<br>')) <!-- read-only html of address -->
@endforeach 
You can make call direcly on the Conner\Addresses\Address model if you want. But you just have to be careful when reading/writing. The methods provided on \Addresses handle checks against the currently logged in user and making sure there are no duplicate primary addresses.