© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
16 replies
Garrita

Save Spatie Media Library File in Relationship

I have a form resource where I save the child and the parent but when I try to save the files for the parent it does not store them, just the other attributes except the files.

Models: AuctionCar belongsTo Car

AuctionCarResource.php
In this case, I save the mileage and the license plate for the parent, but it does not save the images.

Group::make()
  ->relationship('car')
  ->schema([
      TextInput::make('mileage')
          ->label(__('Mileage'))
          ->numeric()
          ->suffix(__('km.'))
          ->required(),

      TextInput::make('license_plate')
          ->label(__('License Plate'))
          ->unique('cars', 'license_plate', ignoreRecord: true)
          ->live()
          ->afterStateUpdated(function (HasForms $livewire, TextInput $component) {
              $livewire->validateOnly($component->getStatePath());
          })
          ->required(),

      SpatieMediaLibraryFileUpload::make('images')
          ->label(__('Images'))
          ->multiple()
          ->image()
          ->required(),
  ])
  ->columns(3)`
  ->columnSpan(3),
Group::make()
  ->relationship('car')
  ->schema([
      TextInput::make('mileage')
          ->label(__('Mileage'))
          ->numeric()
          ->suffix(__('km.'))
          ->required(),

      TextInput::make('license_plate')
          ->label(__('License Plate'))
          ->unique('cars', 'license_plate', ignoreRecord: true)
          ->live()
          ->afterStateUpdated(function (HasForms $livewire, TextInput $component) {
              $livewire->validateOnly($component->getStatePath());
          })
          ->required(),

      SpatieMediaLibraryFileUpload::make('images')
          ->label(__('Images'))
          ->multiple()
          ->image()
          ->required(),
  ])
  ->columns(3)`
  ->columnSpan(3),
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Spatie Media Library
FilamentFFilament / ❓┊help
10mo ago
Spatie Media Library
FilamentFFilament / ❓┊help
14mo ago
spatie media library file upload load file
FilamentFFilament / ❓┊help
2y ago
Spatie Media Library custom file name
FilamentFFilament / ❓┊help
2y ago