Skip to content

Commit

Permalink
fix(provider): add missing config in provider
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre Batistella Bellas committed Jul 7, 2023
1 parent 55e7c3f commit 36c6268
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/DuskApiConfServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Manyapp\DuskApiConf;

use Illuminate\Support\Facades\Storage;
use Illuminate\Support\ServiceProvider;

class DuskApiConfServiceProvider extends ServiceProvider
Expand All @@ -13,20 +14,28 @@ class DuskApiConfServiceProvider extends ServiceProvider
*/
public function boot()
{
$this->loadRoutesFrom(__DIR__.'/Routes/Route.php');
$this->loadViewsFrom(__DIR__.'/Resources/Views', 'duskapiconf');
$this->loadRoutesFrom(__DIR__ . '/Routes/Route.php');
$this->loadViewsFrom(__DIR__ . '/Resources/Views', 'duskapiconf');

$this->mergeConfigFrom(
__DIR__.'/../config/config.php',
__DIR__ . '/../config/config.php',
'manyapp.duskapiconf'
);

$contents = Storage::disk(config('manyapp.duskapiconf.disk'))->get(config('manyapp.duskapiconf.file'));
$decoded = json_decode($contents, true);
foreach (array_keys($decoded) as $k) {
config([$k => $decoded[$k]]);
}

$this->publishes([
__DIR__.'/../config/config.php' => config_path('duskapiconf.php'),
__DIR__ . '/../config/config.php' => config_path('duskapiconf.php'),
]);

$router = $this->app['router'];
$router->pushMiddlewareToGroup('web', \Manyapp\DuskApiConf\Middleware\ConfigStoreMiddleware::class);
$this->app->booted(function () use ($router) {
$router->pushMiddlewareToGroup('web', \Manyapp\DuskApiConf\Middleware\ConfigStoreMiddleware::class);
});
}

/**
Expand All @@ -37,4 +46,4 @@ public function boot()
public function register()
{
}
}
}

0 comments on commit 36c6268

Please sign in to comment.