*/ protected $fillable = [ 'key', 'value', 'type', 'created_at', 'updated_at', ]; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'type' => SettingTypesEnum::class ]; // * EVENTS /** * Perform any actions required after the model boots. * * @return void */ protected static function booted(): void { static::updating(function (self $model) { if ( $model->key === "SquaredLogo" || $model->key === "RectangleLogo" || $model->key === "BackgroundImage" || $model->key === "HomeButtonImage" ) { $model->value = FileStorageHelper::storeFile($model, $model->value, true); } }); static::deleted(function (self $model) { if ( $model->key === "SquaredLogo" || $model->key === "RectangleLogo" || $model->key === "BackgroundImage" || $model->key === "HomeButtonImage" ) { FileStorageHelper::removeFile($model, 'value'); } }); } }