pedi2/app/Http/Controllers/ComprasController.php

60 lines
1.5 KiB
PHP
Raw Normal View History

<?php
namespace App\Http\Controllers;
use App\GrupoDeCompra;
2024-12-21 14:57:03 -03:00
use App\Helpers\CanastaHelper;
use App\Producto;
use Illuminate\Http\Request;
class ComprasController
{
2024-12-21 14:57:03 -03:00
const CANASTAS_PATH = 'csv/canastas/';
public function indexPedidos() {
return view('compras_pedidos');
}
public function descargarPedidos() {
Producto::planillaTotales();
2024-12-09 21:13:51 -03:00
$file = resource_path('csv/exports/pedidos-por-barrio.csv');
return response()->download($file);
}
public function descargarNotas() {
Producto::planillaNotas();
$file = resource_path('csv/exports/notas-por-barrio.csv');
return response()->download($file);
}
public function descargarTransporte() {
GrupoDeCompra::planillaTransporte();
$file = resource_path('csv/exports/transporte-por-barrio.csv');
return response()->download($file);
}
2024-09-14 13:37:06 -03:00
public function show()
{
return view('auth/compras_login');
}
public function cargarCanasta(Request $request)
{
$request->validate([
'data' => 'required|file|mimes:csv,txt|max:2048',
]);
$nombre = CanastaHelper::guardarCanasta($request->file('data'), self::CANASTAS_PATH);
2024-12-21 14:57:03 -03:00
CanastaHelper::cargarCanasta(self::CANASTAS_PATH . $nombre);
return response()->json([
'message' => 'Canasta cargada exitosamente',
], 200);
}
public function descargarCanastaEjemplo() {
$file = resource_path('csv/productos.csv');
return response()->download($file);
}
}