form->fill(); } public function form(Schema $form): Schema { return $form ->schema([ Select::make('supplier_id') ->label('Beszállító') ->options(Supplier::query()->pluck('name', 'id')) ->required() ->searchable(), DatePicker::make('available_date') ->label('Életbelépés dátuma') ->required() ->native(false) ->displayFormat('Y.m.d'), Textarea::make('note') ->label('Megjegyzés') ->rows(3), FileUpload::make('filename') ->label('Fájl kiválasztása') ->required() ->acceptedFileTypes(['application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv']) ->disk('public') ->directory('pricelist-uploads') ->preserveFilenames(), ]) ->statePath('data'); } protected function getFormActions(): array { return [ Action::make('save') ->label('Feltöltés és feldolgozás indítása') ->submit('save') ->color('primary'), ]; } public function save() { $data = $this->form->getState(); $pricelistFile = PricelistFile::create([ 'filename' => $data['filename'], 'supplier_id' => $data['supplier_id'], 'available_date' => $data['available_date'], 'note' => $data['note'], 'status' => \App\Enums\PricelistFileStatusEnum::todo, 'workflow_steps' => [ ['name' => 'preprocess', 'label' => 'Előfeldolgozás', 'status' => 'pending'], ['name' => 'validation', 'label' => 'Validálás', 'status' => 'pending'], ['name' => 'approval', 'label' => 'Jóváhagyás', 'status' => 'pending'], ['name' => 'execution', 'label' => 'Végrehajtás', 'status' => 'pending'] ], ]); PricelistPreProcessJob::dispatch($pricelistFile); Notification::make() ->title('Sikeres feltöltés') ->body('Az árlista fájl rögzítve lett és a feldolgozás elindult.') ->success() ->send(); $this->form->fill(); return redirect()->to(PricelistFileResource::getUrl('view', ['record' => $pricelistFile])); } }