© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
16 replies
benjji92

how to pass uploaded file as variable in table builder?

public static function table(Table $table): Table
    {
        return $table
            ->columns([
          //
            ])
            ->filters([
               //
            ])
            ->actions([
                Tables\Actions\Action::make('Run')
                ->label('Run script')
                ->color('danger')
                ->size('lg')
                ->icon('heroicon-o-play')
                ->requiresConfirmation()
                ->form([
                    SpatieMediaLibraryFileUpload::make('excel')
                        ->label('Excel')
                        ->collection('excel')
                        ->preserveFilenames(),
                ])
                ->action (function (Request $request)  {
                    $command = new \App\Console\Commands\DeleteData();
                    $file = $request->file('excel');
                    return $command->handle($file);
                })
            ])
            ->bulkActions([
                //
            ]);
    }
public static function table(Table $table): Table
    {
        return $table
            ->columns([
          //
            ])
            ->filters([
               //
            ])
            ->actions([
                Tables\Actions\Action::make('Run')
                ->label('Run script')
                ->color('danger')
                ->size('lg')
                ->icon('heroicon-o-play')
                ->requiresConfirmation()
                ->form([
                    SpatieMediaLibraryFileUpload::make('excel')
                        ->label('Excel')
                        ->collection('excel')
                        ->preserveFilenames(),
                ])
                ->action (function (Request $request)  {
                    $command = new \App\Console\Commands\DeleteData();
                    $file = $request->file('excel');
                    return $command->handle($file);
                })
            ])
            ->bulkActions([
                //
            ]);
    }


i would like to pass the excel file i upload here to the deletescript, but i dont understand how this works


class DeleteScript
{
    public function delete()
    {
        $data = Excel::toArray([], $file);

        $dataChunks = array_chunk($data[0], 25);

        foreach ($dataChunks as $chunk) {
           //rest of the code
        }
    }
}
class DeleteScript
{
    public function delete()
    {
        $data = Excel::toArray([], $file);

        $dataChunks = array_chunk($data[0], 25);

        foreach ($dataChunks as $chunk) {
           //rest of the code
        }
    }
}



class DeleteData extends Command
{
    protected $signature = 'delete:data';
    protected $description = 'Delete Data';
    public function handle()
{
    (new DeleteScript())->delete();
    return Command::SUCCESS;
}
}
class DeleteData extends Command
{
    protected $signature = 'delete:data';
    protected $description = 'Delete Data';
    public function handle()
{
    (new DeleteScript())->delete();
    return Command::SUCCESS;
}
}
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

Undefined variable $table while using table builder
FilamentFFilament / ❓┊help
3y ago
Pass query string parameters to Table Builder in v3
FilamentFFilament / ❓┊help
3y ago
How to get uploaded file in page action
FilamentFFilament / ❓┊help
3y ago
How to display multiple images in table builder
FilamentFFilament / ❓┊help
3y ago