Skip to content

Commit

Permalink
change the way we register the configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanpmartins committed Jan 6, 2023
1 parent 05b181b commit 5d210cd
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 28 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ Laravel Package for integration with [Stays](https://stays.net/) External API. D
composer require jonathanpmartins/staysvel;
```

Search for the `Staysvel\StaysServiceProvider` provider to publish the config file called `stays.php`.
```shell
php artisan vendor:publish;
Add the following code to your `config\services.php` configuration file:
```php
'stays' => [
'endpoint' => env('STAYS_ENDPOINT'),
'client_id' => env('STAYS_CLIENT_ID'),
'client_secret' => env('STAYS_CLIENT_SECRET'),
],
```

Add the following keys to you `.env` file and fill them up with your credentials.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "jonathanpmartins/staysvel",
"description": "Laravel Package for integration with Stays External API.",
"license": "MIT",
"version": "1.0.0",
"version": "1.0.1",
"authors": [
{
"name": "Jonathan Martins",
Expand Down
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions config/stays.php

This file was deleted.

13 changes: 2 additions & 11 deletions src/StaysServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@ class StaysServiceProvider extends ServiceProvider
{
public function boot()
{
$this->publishes([
__DIR__ . '/../config/stays.php' => $this->config_path('stays.php'),
]);
$token = base64_encode($this->config('services.stays.client_id').':'.$this->config('services.stays.client_secret'));

$token = base64_encode($this->config('stays.client_id').':'.$this->config('stays.client_secret'));

$endpoint = $this->config('stays.endpoint').'/external/v1';
$endpoint = $this->config('services.stays.endpoint').'/external/v1';

Http::macro('stays', function () use ($token, $endpoint)
{
Expand All @@ -43,11 +39,6 @@ public function register()
});
}

private function config_path($path = '')
{
return $this->app()->configPath($path);
}

private function config($key = null)
{
return $this->app('config')->get($key);
Expand Down

0 comments on commit 5d210cd

Please sign in to comment.