*/ protected $fillable = [ 'picture', 'picture_alt', 'picture_title', 'published', ]; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'published' => 'bool', ]; /** * Perform any actions required after the model boots. * * @return void */ protected static function booted(): void { static::creating(function (self $model) { $model->picture = FileStorageHelper::storeFile($model, $model->picture, true); }); static::updating(function (self $model) { $model->picture = FileStorageHelper::storeFile($model, $model->picture, true); }); static::updated(function (self $model) { FileStorageHelper::removeOldFile($model, 'picture'); Cache::forget('randomStampsFooter'); }); static::deleted(function (self $model) { FileStorageHelper::removeFile($model, 'picture'); Cache::forget('randomStampsFooter'); }); static::created(function () { Cache::forget('randomStampsFooter'); }); } }