validate([ 'csv' => 'required|file|mimetypes:text/plain,text/csv,application/vnd.ms-excel,application/csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'delimiter' => 'nullable|string|in:;,|,', 'dry_run' => 'nullable|boolean', ]); $delimiter = $request->input('delimiter', ','); $dryRun = $request->boolean('dry_run', false); $path = $request->file('csv')->store('imports'); $fullPath = Storage::path($path); $importer = new CardCsvImporter(); [$inserted, $updated, $skipped] = $importer->import($fullPath, $delimiter, $dryRun); return response()->json([ 'inserted' => $inserted, 'updated' => $updated, 'skipped' => $skipped, 'dry_run' => $dryRun, 'path' => $path, ]); } }