GeneralConfigType::class ]; protected $casts = [ 'data' => 'array' ]; protected $primaryKey = 'type'; public $incrementing = false; protected $fillable = [ 'type', 'data' ]; protected static function booted() { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass static::created(function (GeneralConfig $config) { Cache::delete('GeneralConfigGlobal'); }); // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass static::updated(function (GeneralConfig $config) { Cache::delete('GeneralConfigGlobal'); }); // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass static::deleted(function (GeneralConfig $config) { Cache::delete('GeneralConfigGlobal'); }); } public static function getCachedConfigs() { if (!Cache::has('GeneralConfigGlobal')) { self::setCachedConfigs(); } return Cache::get('GeneralConfigGlobal'); } protected static function setCachedConfigs() { $configs = GeneralConfig::all(); Cache::put('GeneralConfigGlobal', $configs); } }