Excel Import Issue

Hi,

I am trying to add additional fields to table header action beside just filupload.

So goal is to add additional text input next to file upload.


But when i upload excel i am having issue with getting that file in $data from ->action().. Is there any way for me to get that temp file to be read with my custom Excel import?


    ->headerActions([
                Action::make('importProducts')
                    ->label(__('Import Products'))

                    ->form([
                        FileUpload::make('import_file')
                            ->label(__('Upload Excel File'))
                            ->acceptedFileTypes([
                                'text/csv',
                                'application/vnd.ms-excel',
                                'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
                            ])
                            ->placeholder(new HtmlString(__('inputs.drag_and_drop_or_browse')))
                            ->required()
                            ->helperText(__('Upload a CSV or Excel file with columns: title, group_name, catalog_number, catalog_numbers, brand, price, quantity, quality'))
                            ->getUploadedFileNameForStorageUsing(
                                fn (TemporaryUploadedFile $file): string => $file->getClientOriginalName()
                            ),
                    ])
                    ->action(function (array $data) {
                        $temporaryFile = $data['import_file'];

                        ImportProductsFromExcel::dispatch($temporaryFile, auth()->user());

                        Notification::make()
                            ->title(__('Import Started'))
                            ->body(__('Your product import is being processed in the background.'))
                            ->success()
                            ->send();
                    })

            ])
Was this page helpful?