*/ protected $fillable = [ 'section_id', 'type', 'data', 'order', ]; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'type' => BlockTypeEnum::class, 'data' => 'object', ]; /** * Get the section that owns this block. * * @return BelongsTo */ public function section(): BelongsTo { return $this->belongsTo(SectionPage::class); } protected static function booted(): void { static::updating(function (self $block) { $picture = request()->file('data.picture.value'); if ($picture instanceof UploadedFile) { $data = $block->data; $data->picture->value = FileStorageHelper::storeFile($block, $picture, true); $block->data = $data; } }); } }