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([ // ]); }

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