forked from miguel456/rbrecruiter
RSM-81 Fix issues with Options provider
This commit is contained in:
parent
b2adcee51e
commit
2a43e213f9
|
@ -3,7 +3,17 @@
|
|||
|
||||
namespace App\Facades;
|
||||
use \Illuminate\Support\Facades\Facade;
|
||||
use phpDocumentor\Reflection\Types\Boolean;
|
||||
|
||||
/**
|
||||
* Class Options
|
||||
* @package App\Facades
|
||||
*
|
||||
* @method static void setOption(string $option, string $value, string $description)
|
||||
* @method static string getOption(string $option)
|
||||
* @method static void changeOption(string $option, string $newValue)
|
||||
* @method static Boolean optionExists(string $option)
|
||||
*/
|
||||
class Options extends Facade
|
||||
{
|
||||
public static function getFacadeAccessor()
|
||||
|
|
|
@ -13,9 +13,12 @@ class Options
|
|||
public function getOption(string $option): string
|
||||
{
|
||||
$value = Cache::get($option);
|
||||
$fromCache = true;
|
||||
|
||||
if (is_null($value))
|
||||
{
|
||||
$fromCache = false;
|
||||
|
||||
Log::debug('Option ' . $option . 'not found in cache, refreshing from database');
|
||||
$value = Option::where('option_name', $option)->first();
|
||||
if (is_null($value))
|
||||
|
@ -25,7 +28,9 @@ class Options
|
|||
Cache::put($option . '_desc', 'Undefined description');
|
||||
}
|
||||
|
||||
return $value->option_value;
|
||||
return (!$fromCache)
|
||||
? $value->option_value
|
||||
: $value;
|
||||
}
|
||||
|
||||
public function setOption(string $option, string $value, string $description)
|
||||
|
|
|
@ -26,7 +26,8 @@ class NewApplicant extends Notification implements ShouldQueue
|
|||
/**
|
||||
* Create a new notification instance.
|
||||
*
|
||||
* @return void
|
||||
* @param Application $application
|
||||
* @param Vacancy $vacancy
|
||||
*/
|
||||
public function __construct(Application $application, Vacancy $vacancy)
|
||||
{
|
||||
|
|
|
@ -8,6 +8,7 @@ class Options extends Model
|
|||
{
|
||||
public $fillable = [
|
||||
'option_name',
|
||||
'option_value'
|
||||
'option_value',
|
||||
'friendly_name'
|
||||
];
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ class DefaultOptionsSeeder extends Seeder
|
|||
|
||||
Options::setOption('enable_slack_notifications', true, 'Enable slack notifications');
|
||||
Options::setOption('enable_email_notifications', true, 'Enable e-mail notifications');
|
||||
Options::setOption('enable_discord_notifications', true, 'Enable discord notifications');
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue