Looking to hire Laravel developers? Try LaraJobs

laravel-getting-locations maintained by antonamosov

Description
A getting of JSON-encoded locations data stored in predefined format.
Author
Last update
2018/12/22 15:40 (dev-master)
License
Downloads
15
Tags

Comments
comments powered by Disqus

Laravel Getting Locations

An laravel package for a getting of locations using custom service.

Installation

Require this package with composer using the following command:

$ composer require "antonamosov/laravel-getting-locations @dev"

After updating composer, add the service provider to the providers array in config/app.php

Antonamosov\LaravelGettingLocations\LaravelGettingLocationsServiceProvider::class,

And add the alias to aliases array in config/app.php

'GettingLocations' => Antonamosov\LaravelGettingLocations\Facades\LaravelGettingLocations::class,

Publish the config file to change implementations, select service and API key:

$ php artisan vendor:publish --provider="Antonamosov\LaravelGettingLocations\LaravelGettingLocationsServiceProvider" --tag="config"

Usage

use LaravelGettingLocations;

$response = LaravelGettingLocations::getLocations([
        'name' => 'Moscow City',
        'address' => 'Lenina',
        'postalCode' => '185000',
        'country' => 'Russia',
    ]);
        
if ($response->success) {
        foreach ($response->data->locations as $location) {
            echo $location->name . "\n";
            echo $location->coordinates->lat . "\n";
            echo $location->coordinates->long . "\n\n";
        }
    }        

Testing

./vendor/bin/phpunit vendor/antonamosov/laravel-getting-locations/tests/LaravelGettingLocationsTest.php