*/ protected $fillable = [ 'picture_1', 'picture_1_alt', 'picture_1_title', 'picture_2', 'picture_2_alt', 'picture_2_title', 'picture_3', 'picture_3_alt', 'picture_3_title', ]; /** * Perform any actions required after the model boots. * * @return void */ protected static function booted(): void { static::creating(function () { throw new \RuntimeException("Creating a new page is not authorized"); }); static::updating(function (self $model) { $model->picture_1 = FileStorageHelper::storeFile($model, $model->picture_1, true); $model->picture_2 = FileStorageHelper::storeFile($model, $model->picture_2, true); $model->picture_3 = FileStorageHelper::storeFile($model, $model->picture_3, true); }); static::updated(function (self $model) { FileStorageHelper::removeOldFile($model, 'picture_1'); FileStorageHelper::removeOldFile($model, 'picture_2'); FileStorageHelper::removeOldFile($model, 'picture_3'); }); static::deleting(function () { throw new \RuntimeException('Deleting a page is not authorized'); }); } // * RELATIONS /** * The commitments that belong to the page. * * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function commitments(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { return $this->belongsToMany(Commitment::class); } }