From 57b8d6bcceb4206bf10ec7af1fd310a0b956a696 Mon Sep 17 00:00:00 2001 From: ale Date: Sat, 21 Dec 2024 14:57:03 -0300 Subject: [PATCH] Agregada logica para cargar canasta --- app/Http/Controllers/ComprasController.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/ComprasController.php b/app/Http/Controllers/ComprasController.php index 48ee549..d30db9d 100644 --- a/app/Http/Controllers/ComprasController.php +++ b/app/Http/Controllers/ComprasController.php @@ -3,11 +3,14 @@ namespace App\Http\Controllers; use App\GrupoDeCompra; +use App\Helpers\CanastaHelper; use App\Producto; use Illuminate\Http\Request; class ComprasController { + const CANASTAS_PATH = 'csv/canastas/'; + public function indexPedidos() { return view('compras_pedidos'); } @@ -41,9 +44,11 @@ class ComprasController 'data' => 'required|file|mimes:csv,txt|max:2048', ]); - $archivo = $request->file('data'); - $path = resource_path('/csv/canastas/'); - $archivo->move($path, $archivo->getClientOriginalName()); + $data = $request->file('data'); + $nombre = $data->getClientOriginalName(); + + $data->move(resource_path(self::CANASTAS_PATH), $nombre); + CanastaHelper::cargarCanasta(self::CANASTAS_PATH . $nombre); return response()->json([ 'message' => 'Canasta cargada exitosamente',