Skip to content

Commit

Permalink
write a new file on first run, and fix routes
Browse files Browse the repository at this point in the history
  • Loading branch information
ReeceM committed May 5, 2019
1 parent 9c6916f commit 29dbe7a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
*/
use Illuminate\Support\Facades\Route;

Route::get(config('setting.path') . '/settings/refresh', 'SettingController@refresh')->name('refresh');
Route::resource(config('setting.path') . '/settings', 'SettingController');
Route::get('/settings/refresh', 'SettingController@refresh')->name('settings.refresh');
Route::resource('/settings', 'SettingController');
9 changes: 7 additions & 2 deletions src/Services/SettingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public function cache()
$this->files->put(
$configPath, '<?php return '.var_export($this->settings, true).';'.PHP_EOL
);
return true;
}
/**
* Reads the settings file into memory
Expand All @@ -81,8 +82,12 @@ public function load()
try {
$this->settings = $this->files->getRequire(base_path('bootstrap/cache/' . static::$configName));
} catch (\Exception $e) {
Log::critical('Failed to load system settings with error: ' . $e);
throw $e;

if(! $this->cache()) {
Log::critical('Failed to load system settings with error: ' . $e);
session()->flash('setting.flash.danger', 'Failed to load system settings file from storage');
}
// throw $e;
}
}
/**
Expand Down

0 comments on commit 29dbe7a

Please sign in to comment.