© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
21 replies
anjama

Laravel Excel not running in action

I have a csv importer built using Laravel Excel that works when tested in a seeder and in Tinker, but when using it with a file upload form inside of a modal, it seems like it's being skipped entirely inside of the action (doesn't even throw exceptions when there is an issue). Other code before and after the import inside of the action runs fine. Can anyone spot something I'm doing wrong?

Action::make('import')
                ->form([
                    FileUpload::make('data_file')
                        ->acceptedFileTypes(['text/csv'])
                        ->maxFiles(1)
                        ->storeFileNamesIn('file_name')
                ])
                ->action(function (array $data): void {
                    //dd($data);
                    //try {
                        Excel::import(new SitesImport, 'test_data/test_sites.csv'); //Manual file name for debugging
                    //} catch (ValidationException $e) {
                    //    dd($e->failures());
                    //}

                    Notification::make()
                        ->title('Imported: ' . $data['file_name'])
                        ->success()
                        ->send();
                })
Action::make('import')
                ->form([
                    FileUpload::make('data_file')
                        ->acceptedFileTypes(['text/csv'])
                        ->maxFiles(1)
                        ->storeFileNamesIn('file_name')
                ])
                ->action(function (array $data): void {
                    //dd($data);
                    //try {
                        Excel::import(new SitesImport, 'test_data/test_sites.csv'); //Manual file name for debugging
                    //} catch (ValidationException $e) {
                    //    dd($e->failures());
                    //}

                    Notification::make()
                        ->title('Imported: ' . $data['file_name'])
                        ->success()
                        ->send();
                })
Solution
So it turns out you were on the right track. I tried giving a bad file name intentionally, and it didn't change the behavior (no exception), which made me realize that the app must be looking for the data in a different place than when I run it from the command line in tinker or a seeder. Sure enough, it's because my test data is in it's own project folder, and moving it to the storage folder fixed it.
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Excel upload validation in Resource Action
FilamentFFilament / ❓┊help
3y ago
Excel:download() not triggering from BulkAction Action.
FilamentFFilament / ❓┊help
11mo ago
Enhancing Error Handling in Laravel-Excel Integration with FilementPHP
FilamentFFilament / ❓┊help
3y ago
Action is always loading when running a laravel process
FilamentFFilament / ❓┊help
15mo ago