@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if (! function_exists('variable')) { |
|
| 3 | +if (!function_exists('variable')) { |
|
| 4 | 4 | /** |
| 5 | 5 | * @param $name |
| 6 | 6 | * @param null $default |
@@ -25,9 +25,9 @@ |
||
| 25 | 25 | | ----------------------------------------------------------------- |
| 26 | 26 | */ |
| 27 | 27 | 'variable_config' => [ |
| 28 | - 'app_name' => 'app.name', // config('app.name') |
|
| 29 | - 'app_description' => 'app.description', // config('app.description') |
|
| 30 | - 'some_var' => 'services.some.var', // config('services.some.var') |
|
| 28 | + 'app_name' => 'app.name', // config('app.name') |
|
| 29 | + 'app_description' => 'app.description', // config('app.description') |
|
| 30 | + 'some_var' => 'services.some.var', // config('services.some.var') |
|
| 31 | 31 | ], |
| 32 | 32 | |
| 33 | 33 | /* ----------------------------------------------------------------- |
@@ -37,8 +37,8 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | public function __construct($variableModel, $cacheRepository, $app = null) |
| 39 | 39 | { |
| 40 | - if (! $app) { |
|
| 41 | - $app = app(); //Fallback when $app is not given |
|
| 40 | + if (!$app) { |
|
| 41 | + $app = app(); //Fallback when $app is not given |
|
| 42 | 42 | } |
| 43 | 43 | $this->app = $app; |
| 44 | 44 | |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | return $this->cacheRepository->remember( |
| 160 | 160 | $this->config['cache']['name'], |
| 161 | 161 | $this->config['cache']['time'], |
| 162 | - function () { |
|
| 162 | + function() { |
|
| 163 | 163 | return $this->getVariableModel()->all(); |
| 164 | 164 | }); |
| 165 | 165 | } else { |
@@ -19,22 +19,22 @@ |
||
| 19 | 19 | ], 'config'); |
| 20 | 20 | |
| 21 | 21 | if (! class_exists('CreateVariablesTable')) { |
| 22 | - $timestamp = date('Y_m_d_His', time()); |
|
| 22 | + $timestamp = date('Y_m_d_His', time()); |
|
| 23 | 23 | |
| 24 | - $this->publishes([ |
|
| 25 | - __DIR__.'/../database/migrations/create_variables_table.php.stub' => $this->app->databasePath()."/migrations/{$timestamp}_create_variables_table.php", |
|
| 26 | - ], 'migrations'); |
|
| 24 | + $this->publishes([ |
|
| 25 | + __DIR__.'/../database/migrations/create_variables_table.php.stub' => $this->app->databasePath()."/migrations/{$timestamp}_create_variables_table.php", |
|
| 26 | + ], 'migrations'); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | $this->replaceConfigsWithVariables(); |
| 30 | 30 | |
| 31 | 31 | if ($this->app->runningInConsole()) { |
| 32 | - $this->commands([ |
|
| 33 | - Commands\AllVariable::class, |
|
| 34 | - Commands\GetVariable::class, |
|
| 35 | - Commands\SaveVariable::class, |
|
| 36 | - Commands\CacheClearVariable::class, |
|
| 37 | - ]); |
|
| 32 | + $this->commands([ |
|
| 33 | + Commands\AllVariable::class, |
|
| 34 | + Commands\GetVariable::class, |
|
| 35 | + Commands\SaveVariable::class, |
|
| 36 | + Commands\CacheClearVariable::class, |
|
| 37 | + ]); |
|
| 38 | 38 | } |
| 39 | 39 | } |
| 40 | 40 | |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | __DIR__.'/../config/variables.php' => config_path('variables.php'), |
| 19 | 19 | ], 'config'); |
| 20 | 20 | |
| 21 | - if (! class_exists('CreateVariablesTable')) { |
|
| 21 | + if (!class_exists('CreateVariablesTable')) { |
|
| 22 | 22 | $timestamp = date('Y_m_d_His', time()); |
| 23 | 23 | |
| 24 | 24 | $this->publishes([ |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | $this->mergeConfigFrom(__DIR__.'/../config/variables.php', 'variables'); |
| 49 | 49 | |
| 50 | - $this->app->singleton(VariableManagerContract::class, function () { |
|
| 50 | + $this->app->singleton(VariableManagerContract::class, function() { |
|
| 51 | 51 | $cacheRepo = $this->app->make(\Illuminate\Cache\Repository::class); |
| 52 | 52 | $variableModel = $this->app['config']->get('variables.model_name'); |
| 53 | 53 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | protected function replaceConfigsWithVariables() |
| 59 | 59 | { |
| 60 | - $this->app->booted(function () { |
|
| 60 | + $this->app->booted(function() { |
|
| 61 | 61 | |
| 62 | 62 | // Package config |
| 63 | 63 | $config = $this->app['config']->get('variables'); |
@@ -69,11 +69,11 @@ discard block |
||
| 69 | 69 | $variables = $this->app->make(VariableManagerContract::class)->all(); |
| 70 | 70 | |
| 71 | 71 | foreach ($variables as $var) { |
| 72 | - if (! empty($variableConfig[$var->key])) { |
|
| 72 | + if (!empty($variableConfig[$var->key])) { |
|
| 73 | 73 | $this->app['config']->set($variableConfig[$var->key], $var->value); |
| 74 | 74 | } |
| 75 | - if (! empty($config['config_key_for_vars'])) { |
|
| 76 | - $this->app['config']->set($config['config_key_for_vars'] . '.' . $var->key, $var->value); |
|
| 75 | + if (!empty($config['config_key_for_vars'])) { |
|
| 76 | + $this->app['config']->set($config['config_key_for_vars'].'.'.$var->key, $var->value); |
|
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | } catch (\Exception $exception) { |
@@ -23,6 +23,6 @@ |
||
| 23 | 23 | // ->setIsUseCache($this->option('cache')) |
| 24 | 24 | ->get($this->argument('key'), null, $this->option('langcode'), $useCache); |
| 25 | 25 | |
| 26 | - print_r($variable . "\n"); |
|
| 26 | + print_r($variable."\n"); |
|
| 27 | 27 | } |
| 28 | 28 | } |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | public function byLangcode($query, ?string $langcode = null) |
| 32 | 32 | { |
| 33 | 33 | return $query->when($langcode, function ($q) use ($langcode) { |
| 34 | - $q->where('langcode', $langcode); |
|
| 34 | + $q->where('langcode', $langcode); |
|
| 35 | 35 | }); |
| 36 | 36 | } |
| 37 | 37 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | protected static function booted() |
| 23 | 23 | { |
| 24 | - static::saved(function ($model) { |
|
| 24 | + static::saved(function($model) { |
|
| 25 | 25 | if (config('variables.cache.autoclear')) { |
| 26 | 26 | app(\Fomvasss\Variable\VariableManagerContract::class)->cacheClear(); |
| 27 | 27 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | public function byLangcode($query, ?string $langcode = null) |
| 32 | 32 | { |
| 33 | - return $query->when($langcode, function ($q) use ($langcode) { |
|
| 33 | + return $query->when($langcode, function($q) use ($langcode) { |
|
| 34 | 34 | $q->where('langcode', $langcode); |
| 35 | 35 | }); |
| 36 | 36 | } |