aa
This commit is contained in:
@@ -11,15 +11,26 @@ use App\Article;
|
||||
|
||||
class ArticleController extends Controller
|
||||
{
|
||||
private function queryTest(){
|
||||
$articoli = DB::table('T_WEB_Articoli as A')
|
||||
->leftJoin(DB::raw('(SELECT CodArticoloGM, SUM(Qta) as totaleVenduti FROM T_WEB_Ordini GROUP BY CodArticoloGM) O'), 'A.IdArticolo', '=', 'O.CodArticoloGM')
|
||||
->select('A.IdArticolo', 'A.Titolo', DB::raw('COALESCE(O.totaleVenduti, 0) as totaleVenduti'))
|
||||
->orderBy('totaleVenduti', 'desc')
|
||||
->get();
|
||||
private function queryTest()
|
||||
{
|
||||
try {
|
||||
$articoli = DB::table('T_WEB_Articoli as A')
|
||||
->leftJoin(DB::raw('(SELECT CodArticoloGM, SUM(Qta) as totaleVenduti FROM T_WEB_Ordini GROUP BY CodArticoloGM) O'), 'A.IdArticolo', '=', 'O.CodArticoloGM')
|
||||
->select('A.IdArticolo', 'A.Titolo', DB::raw('COALESCE(O.totaleVenduti, 0) as totaleVenduti'))
|
||||
->orderBy('totaleVenduti', 'desc')
|
||||
->get();
|
||||
|
||||
if ($articoli->isEmpty()) {
|
||||
return response()->json(['message' => 'Nessun articolo trovato.'], 404);
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
// Registrazione dell'errore
|
||||
return response()->json(['error' => 'Si è verificato un errore durante il recupero dei dati: ' . $e->getMessage()], 500);
|
||||
}
|
||||
|
||||
return $articoli;
|
||||
|
||||
return $articoli;
|
||||
|
||||
}
|
||||
private function queryArticlesSales()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user