forked from miguel456/rbrecruiter
Added logging to Settings
This commit is contained in:
parent
ea96cbc1f5
commit
2afea88846
|
@ -5,6 +5,7 @@ namespace App\Helpers;
|
|||
|
||||
use App\Options as Option;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class Options
|
||||
{
|
||||
|
@ -15,6 +16,7 @@ class Options
|
|||
|
||||
if (is_null($value))
|
||||
{
|
||||
Log::info('Option ' . $option . 'not found in cache, refreshing from database');
|
||||
$value = Option::where('option_name', $option)->first();
|
||||
if (is_null($value))
|
||||
throw new \Exception('This option does not exist.');
|
||||
|
@ -59,10 +61,19 @@ class Options
|
|||
$dbOptionInstance = Option::find($dbOption->first()->id);
|
||||
Cache::forget($option);
|
||||
|
||||
Log::warning('Changing db configuration option', [
|
||||
'old_value' => $dbOptionInstance->option_value,
|
||||
'new_value' => $newValue
|
||||
]);
|
||||
|
||||
$dbOptionInstance->option_value = $newValue;
|
||||
$dbOptionInstance->save();
|
||||
|
||||
Log::warning('New db configuration option saved',
|
||||
[
|
||||
'option' => $dbOptionInstance->option_value
|
||||
]);
|
||||
|
||||
Cache::put('option_name', $newValue, now()->addDay());
|
||||
}
|
||||
else
|
||||
|
|
|
@ -40,9 +40,8 @@ class OptionsController extends Controller
|
|||
}
|
||||
catch(\Exception $ex)
|
||||
{
|
||||
// Silently ignore, because the only way this would happen is if someone manipulates the page,
|
||||
// and obviously we can't save arbitrary option values even if the user has permission to do so.
|
||||
continue;
|
||||
$request->session()->flash('error', 'An error occurred while trying to save settings: ' . $ex->getMessage());
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue