*/ protected $fillable = [ 'title', 'location', 'contract', 'function', 'picture', 'picture_alt', 'picture_title', 'link', 'description', 'published', 'published_at', ]; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'published' => 'boolean', 'publish_at' => 'datetime', ]; /** * Perform any actions required after the model boots. * * @return void */ protected static function booted(): void { static::creating(function (self $offer) { $offer->picture = FileStorageHelper::storeFile($offer, $offer->picture, true); }); static::updating(function (self $offer) { $offer->picture = FileStorageHelper::storeFile($offer, $offer->picture, true); }); static::updated(function (self $offer) { FileStorageHelper::removeOldFile($offer, 'picture'); }); static::deleted(function (self $offer) { FileStorageHelper::removeFile($offer, 'picture'); }); } }