Without share.

This commit is contained in:
2019-11-15 12:14:38 +03:00
commit b3c03162f1
16 changed files with 898 additions and 0 deletions

62
src/SettingsServiceProvider.php Executable file
View File

@ -0,0 +1,62 @@
<?php namespace Efriandika\LaravelSettings;
use Illuminate\Support\ServiceProvider;
class SettingsServiceProvider extends ServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;
/**
* Bootstrap the application events.
*
* @return void
*/
public function boot()
{
$this->publishes([
__DIR__ . '/config/settings.php' => config_path('settings.php')
]);
$this->publishes([
__DIR__ . '/database/migrations/' => base_path('/database/migrations')
]);
}
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->mergeConfigFrom(
__DIR__ . '/config/settings.php', 'settings'
);
$this->app['settings'] = function ($app) {
$config = $app->config->get('settings', [
'cache_file' => storage_path('settings.json'),
'db_table' => 'settings'
]);
return new Settings($app['db'], new Cache($config['cache_file']), $config);
};
}
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return array ('settings');
}
}