© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
1 reply
prowler

Relation manager custom action + Spatie media library plugin

Hello everyone, i have a relation manager which has a custom action in its
$table
$table
-

Action::make('bom')
                    ->model(Bom::class)
                    ->label('Import Bom')
                    ->form(Bom::getForm())
                    ->action(function ($record, array $data): void {
                        Bom::updateOrCreate([
                            'assembly_id' => $record->id,
                            'bom_name' => $data['bom_name'],
                            'header_row_in_excel' => $data['header_row_in_excel'],
                            'last_row_in_excel' => $data['last_row_in_excel'],
                        ]);
                    })
Action::make('bom')
                    ->model(Bom::class)
                    ->label('Import Bom')
                    ->form(Bom::getForm())
                    ->action(function ($record, array $data): void {
                        Bom::updateOrCreate([
                            'assembly_id' => $record->id,
                            'bom_name' => $data['bom_name'],
                            'header_row_in_excel' => $data['header_row_in_excel'],
                            'last_row_in_excel' => $data['last_row_in_excel'],
                        ]);
                    })


Now, inside
Bom::getForm()
Bom::getForm()
I have a media field using spatie's plugin which looks like this -

SpatieMediaLibraryFileUpload::make('bom_file')
                ->collection('bom_files')
SpatieMediaLibraryFileUpload::make('bom_file')
                ->collection('bom_files')


For some reason, when i upload a file, it is being attached to the parent model (
Assembly
Assembly
) rather than to
Bom
Bom
, even though im explicitly using
->model()
->model()
and the
->form()
->form()
method is referencing to
Bom
Bom
's model as well.. So why is it happening?
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 in Relation Manager
FilamentFFilament / ❓┊help
2y ago
Does Spatie Media Library works with Relation Manager?
FilamentFFilament / ❓┊help
8mo ago
filament spatie media library plugin
FilamentFFilament / ❓┊help
13mo ago
Managing custom properties with Spatie Media Library plugin
FilamentFFilament / ❓┊help
3y ago