Agregado metodo para notas de barrio
This commit is contained in:
parent
56e1a94ee7
commit
092e98a456
1 changed files with 28 additions and 0 deletions
|
@ -103,4 +103,32 @@ class Producto extends Model
|
||||||
$filePath = 'csv/exports/notas-por-barrio-' . $fecha . '.csv';
|
$filePath = 'csv/exports/notas-por-barrio-' . $fecha . '.csv';
|
||||||
CsvHelper::generarCsv($filePath, $planilla, $headers);
|
CsvHelper::generarCsv($filePath, $planilla, $headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws InvalidArgument
|
||||||
|
* @throws CannotInsertRecord
|
||||||
|
*/
|
||||||
|
static public function planillaNotasBarrio($gdc) {
|
||||||
|
$headers = ['Producto'];
|
||||||
|
$barrios = [$gdc->nombre];
|
||||||
|
$headers = array_merge($headers, $barrios);
|
||||||
|
|
||||||
|
$notasPorBarrio = self::notasPorBarrio();
|
||||||
|
$planilla = [];
|
||||||
|
|
||||||
|
foreach ($notasPorBarrio as $producto => $notasGrupo) {
|
||||||
|
$fila = [$producto];
|
||||||
|
foreach ($barrios as $barrio) {
|
||||||
|
$notas = $notasGrupo->where('barrio', $barrio)
|
||||||
|
->pluck('notas')
|
||||||
|
->implode('; ');
|
||||||
|
$fila[] = $notas ?: '';
|
||||||
|
}
|
||||||
|
$planilla[] = $fila;
|
||||||
|
}
|
||||||
|
|
||||||
|
$fecha = now()->format('Y-m-d');
|
||||||
|
$filePath = 'csv/exports/notas-de-' . $gdc->nombre . '-' . $fecha . '.csv';
|
||||||
|
CsvHelper::generarCsv($filePath, $planilla, $headers);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue