fix: preserve territorial scope in catalogue CSV and record local visual QA
This commit is contained in:
@@ -199,15 +199,16 @@ class InvestmentDiscoveryController extends Controller
|
||||
{
|
||||
$records = $catalogue->query($catalogue->filters($request))->limit(1000)->get();
|
||||
|
||||
return response()->streamDownload(function () use ($records) {
|
||||
return response()->streamDownload(function () use ($records, $catalogue) {
|
||||
$stream = fopen('php://output', 'w');
|
||||
if ($stream === false) {
|
||||
return;
|
||||
}
|
||||
fwrite($stream, "\xEF\xBB\xBF");
|
||||
fputcsv($stream, ['Referência', 'Título', 'Sector', 'Província', 'Montante', 'Moeda', 'Maturidade', 'URL'], ';', '"', '');
|
||||
fputcsv($stream, ['Referência', 'Título', 'Sector', 'Província', 'Montante', 'Moeda', 'Maturidade', 'URL', 'Localização e âmbito'], ';', '"', '');
|
||||
foreach ($records as $r) {
|
||||
$fields = [$r->reference, $r->title, $r->sector?->name, $r->province, $r->estimated_investment_amount, $r->estimated_investment_currency, $r->maturity_label, url('/oportunidades/'.$r->slug)];
|
||||
$location = $catalogue->locationPresentation($r);
|
||||
$fields = [$r->reference, $r->title, $r->sector?->name, implode(' / ', $location['provinces']), $r->estimated_investment_amount, $r->estimated_investment_currency, $r->maturity_label, url('/oportunidades/'.$r->slug), $location['summary']];
|
||||
fputcsv($stream, array_map(fn ($v) => preg_match('/^[\s]*[=+@-]/u', (string) $v) ? "'".$v : $v, $fields), ';', '"', '');
|
||||
}
|
||||
fclose($stream);
|
||||
|
||||
Reference in New Issue
Block a user