Skip to content

Commit

Permalink
Merge pull request #8 from pnlinh/feature/minor-patch
Browse files Browse the repository at this point in the history
Minor patch
  • Loading branch information
pnlinh authored Oct 7, 2019
2 parents bd752c0 + 5f57007 commit 1aa0b4b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ Require this package with composer.
composer require pnlinh/laravel-google-distance
```

To publishes config `config/distance.php`, use command:
To publishes config `config/google-distance.php`, use command:

```bash
php artisan vendor:publish --tag="distance-config"
php artisan vendor:publish --tag="google-distance"
```

You must set your [Google Maps API Key](https://developers.google.com/maps/documentation/distance-matrix/get-api-key) GOOGLE_MAPS_DISTANCE_API_KEY in your .env file like so:
Expand Down
10 changes: 6 additions & 4 deletions src/Providers/GoogleDistanceServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ class GoogleDistanceServiceProvider extends ServiceProvider
*/
public function boot()
{
$this->publishes([
__DIR__.'/../config/distance.php' => config_path('distance.php'),
], 'distance-config');
if ($this->app->runningInConsole()) {
$this->publishes([
__DIR__.'/../config/google-distance.php' => config_path('google-distance.php'),
], 'google-distance');
}
}

/**
Expand All @@ -29,7 +31,7 @@ public function boot()
public function register()
{
$this->app->singleton('google-distance', function (Container $app) {
return new GoogleDistance($app['config']['distance.api_key']);
return new GoogleDistance($app['config']['google-distance.api_key']);
});

$this->app->booting(function () {
Expand Down
File renamed without changes.
16 changes: 16 additions & 0 deletions tests/Feature/GoogleDistanceServiceProviderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Pnlinh\GoogleDistance\Tests\Feature;

use Illuminate\Support\ServiceProvider;
use Pnlinh\GoogleDistance\Providers\GoogleDistanceServiceProvider;
use Pnlinh\GoogleDistance\Tests\TestCase;

class GoogleDistanceServiceProviderTest extends TestCase
{
/** @test */
public function it_can_be_constructed()
{
$this->assertInstanceOf(ServiceProvider::class, new GoogleDistanceServiceProvider($this->app));
}
}
1 change: 1 addition & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ public function getPackageProviders($app)

public function getEnvironmentSetUp($app)
{
$app['config']->set('google-distance.api_key', 'foo');
}
}

0 comments on commit 1aa0b4b

Please sign in to comment.