AA
This commit is contained in:
@@ -290,6 +290,8 @@ class ArticleController extends Controller
|
|||||||
->orderBy('totVen', 'desc')
|
->orderBy('totVen', 'desc')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($articoliVenduti->isEmpty()) {
|
if ($articoliVenduti->isEmpty()) {
|
||||||
return response()->json(['message' => 'Nessun articolo trovato.'], 404);
|
return response()->json(['message' => 'Nessun articolo trovato.'], 404);
|
||||||
}
|
}
|
||||||
@@ -299,7 +301,8 @@ class ArticleController extends Controller
|
|||||||
return response()->json(['error' => 'Si è verificato un errore durante il recupero dei dati: ' . $e->getMessage()], 500);
|
return response()->json(['error' => 'Si è verificato un errore durante il recupero dei dati: ' . $e->getMessage()], 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $articoliVenduti;
|
// Restituisci una risposta JSON con i dati
|
||||||
|
return response()->json(['data' => $articoliVenduti]);
|
||||||
|
|
||||||
}
|
}
|
||||||
private function queryArticlesFatturati()
|
private function queryArticlesFatturati()
|
||||||
@@ -564,10 +567,14 @@ class ArticleController extends Controller
|
|||||||
$articoliVenduti = $this->queryArticlesFatturati();
|
$articoliVenduti = $this->queryArticlesFatturati();
|
||||||
} else {
|
} else {
|
||||||
$articoliVenduti = $this->queryArticlesSales();
|
$articoliVenduti = $this->queryArticlesSales();
|
||||||
|
// ritorna response()->json(['data' => $articoliVenduti]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($articoliVenduti->isNotEmpty()) {
|
if ($articoliVenduti->isEmpty()) {
|
||||||
|
return response()->json(['message' => 'Nessun articolo trovato.'], 404);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
// ho i dati in "articoliVenduti->data"
|
||||||
// Mappa i risultati nella struttura JSON desiderata
|
// Mappa i risultati nella struttura JSON desiderata
|
||||||
$result = $articoliVenduti->map(function ($articoloVenduto) {
|
$result = $articoliVenduti->map(function ($articoloVenduto) {
|
||||||
return [
|
return [
|
||||||
@@ -604,8 +611,6 @@ class ArticleController extends Controller
|
|||||||
$response->headers->set('Content-Disposition', 'attachment; filename="ranking_' . $cosa . '_' . date('Y-m-d') . '.json"');
|
$response->headers->set('Content-Disposition', 'attachment; filename="ranking_' . $cosa . '_' . date('Y-m-d') . '.json"');
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
} else {
|
|
||||||
return new Response('Nessun articolo', 500);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user