Download the PHP package craigzearfoss/addressable-trait without Composer
On this page you can find all versions of the php package craigzearfoss/addressable-trait. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download craigzearfoss/addressable-trait
More information about craigzearfoss/addressable-trait
Files in craigzearfoss/addressable-trait
Package addressable-trait
Short Description Trait to add addressable functionality to a Laravel 5.1 eloquent model.
License MIT License
Informations about the package addressable-trait
AddressableTrait for Laravel 5
This adds methods to format addresses and phone numbers to an Eloquent model in Laravel 5. It also adds geocoding functionality using GeocoderLaravel.
The AddressableTrait file is pretty simple and easy to understand so modify it to suit your needs. If you have additional functionality that you would like to see added please let me know.
Composer Install
It can be found on Packagist. The recommended way is through composer.
Edit composer.json
and add:
And install dependencies:
If you do not have Composer installed, run these two commands:
Configuration
In your model add the AddressableTrait.
Usage
The AddressableTrait assumes that your model has the following fields. You are not required to have all of the fields, only the fields that that are needed for the methods you want to use.
firstname
(string) - used byfullname
andreversename
methodslastname
(string) - used byfullname
andreversename
methodsaddress
(string)address2
(string)city
(string)state_id
(integer) - references the fieldabbrev
in astates
tablepostcode
(string)country_id
(integer) - references the fieldabbrev
in acountries
tablelat
(float) nullable - stores the latitude retrieved from GeocoderLaravellng
(float) nullable - stores the longitude retrieved from GeocoderLaravelphone
(string)fax
(string)
Formatting Methods:
fullname
reversename
formattedAddress
formattedPhone
formattedFax
Geocoder Methods
fetchGeocode
- returns the geocode array for the current recordfetchCoordinates
- returns an array with the latitude and longitude for the current recordupdateGeocode
- updates thelat
andlng
fields for the current modellookupGeocode
- makes a call to Google maps for the specified address and return the geocode arrayloopupCoordinates
- makes a call to Google maps for the specified address and returns an array with the latitude and longitudedistance
- calculates the distance between the current record and the specified latitude and longitudescopeDistance
- adds a location coordinate and distance to a query
Changelog
Support
Please open an issue on GitHub
Contributor Code of Conduct
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
License
AddressableModel is released under the MIT License. See the bundled LICENSE file for details.