Metodo para obtener id de tipo_pedido y arreglada query de pedidos de ollas para levantar solo los barrios con pedidos de ollas
This commit is contained in:
parent
66298228e3
commit
bcc4f4a28a
1 changed files with 16 additions and 2 deletions
|
@ -43,7 +43,12 @@ class PedidosExportHelper
|
|||
static public function pedidosDeOllas()
|
||||
{
|
||||
$filePath = "csv/exports/pedidos-de-ollas-" . now()->format('Y-m-d') . ".csv";
|
||||
$barrios = GrupoDeCompra::barriosMenosPrueba()->get();
|
||||
$barrios = GrupoDeCompra::barriosMenosPrueba()
|
||||
->whereHas('subpedidos', function ($query) {
|
||||
$tipo_olla = self::getTipoId('olla');
|
||||
$query->where('tipo_pedido_id', $tipo_olla);
|
||||
})
|
||||
->get();
|
||||
|
||||
$contenido = self::generarContenidoCSV($barrios,
|
||||
fn($grupoId) => "subpedidos.grupo_de_compra_id = $grupoId
|
||||
|
@ -62,7 +67,7 @@ class PedidosExportHelper
|
|||
*/
|
||||
public static function cantidadDeOllasParaCSV(Collection $barrios, Collection $contenido)
|
||||
{
|
||||
$tipo_olla = TipoPedido::where('nombre', 'olla')->first()->id;
|
||||
$tipo_olla = self::getTipoId('olla');
|
||||
|
||||
$parametros = collect(CsvHelper::getRecords(resource_path("csv/parametros.csv"), "No se pudo leer el archivo."));
|
||||
$fila = [
|
||||
|
@ -241,4 +246,13 @@ class PedidosExportHelper
|
|||
}
|
||||
return $transporte;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getTipoId(string $tipo)
|
||||
{
|
||||
$tipo_olla = TipoPedido::where('nombre', $tipo)->first()->id;
|
||||
return $tipo_olla;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue