This commit is contained in:
paoloar77
2024-11-27 17:35:32 +01:00
parent d0fcb0baa3
commit 135690c2a0
2 changed files with 57 additions and 46 deletions

View File

@@ -46,6 +46,10 @@ class ArticleController extends Controller
// ->take(50) // ->take(50)
->get(); ->get();
if ($articoliVenduti->isEmpty()) {
return response()->json(['message' => 'Nessun articolo trovato.'], 404);
}
} catch (\Exception $e) { } catch (\Exception $e) {
// Registrazione dell'errore // Registrazione dell'errore
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);

View File

@@ -1,11 +1,13 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="it"> <html lang="it">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Articoli Venduti</title> <title>Articoli Venduti</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head> </head>
<body> <body>
<div class="container mt-4"> <div class="container mt-4">
<h1 class="mb-4">Articoli Venduti</h1> <h1 class="mb-4">Articoli Venduti</h1>
@@ -28,12 +30,15 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<pre>{{ print_r($articoliVenduti, true) }}</pre>
@if ($articoliVenduti->isEmpty()) @if ($articoliVenduti->isEmpty())
<tr> <tr>
<td colspan="6" class="text-center">Nessun articolo trovato.</td> <td colspan="6" class="text-center">Nessun articolo trovato.</td>
</tr> </tr>
@else @else
@foreach ($articoliVenduti as $articolo) @foreach ($articoliVenduti as $articolo)
@if (isset($articolo->idArticolo))
<tr> <tr>
<td>{{ $articolo->idArticolo }}</td> <td>{{ $articolo->idArticolo }}</td>
<td>{{ $articolo->Titolo }}</td> <td>{{ $articolo->Titolo }}</td>
@@ -48,10 +53,12 @@
<td>{{ $articolo->totaleVendutoUltimoAnno }}</td> <td>{{ $articolo->totaleVendutoUltimoAnno }}</td>
<td>{{ $articolo->totaleVendutoUltimi2Anni }}</td> <td>{{ $articolo->totaleVendutoUltimi2Anni }}</td>
</tr> </tr>
@endif
@endforeach @endforeach
@endif @endif
</tbody> </tbody>
</table> </table>
</div> </div>
</body> </body>
</html> </html>