From ce709a98365c4db9ee61a4e88611f4cd6f8fb0c1 Mon Sep 17 00:00:00 2001 From: paoloar77 Date: Thu, 28 Nov 2024 17:14:50 +0100 Subject: [PATCH] aa --- app/Http/Controllers/ArticleController.php | 29 ++++++++++++++++ resources/views/article_test.php | 39 ++++++++++++++++++++++ routes/web.php | 1 + 3 files changed, 69 insertions(+) create mode 100644 resources/views/article_test.php diff --git a/app/Http/Controllers/ArticleController.php b/app/Http/Controllers/ArticleController.php index ac637c99..95ee5d71 100755 --- a/app/Http/Controllers/ArticleController.php +++ b/app/Http/Controllers/ArticleController.php @@ -70,6 +70,20 @@ class ArticleController extends Controller } } + public function test(Request $request) + { + try { + + $articoli = $this->queryTest(); + + return view('article_test', ['articoli' => $$articoli]); + + } catch (\Exception $e) { + // Potresti considerare di registrare l'errore per debugging + return new Response('Error exporting articles: ' . $e->getMessage(), 500); + + } + } public function exportArticlesSales(Request $request): Response { try { @@ -133,4 +147,19 @@ class ArticleController extends Controller return new Response('Error exporting articles: ' . $e->getMessage(), 500); } } + + private function queryTest(): \Response + { + try { + $duplicati = DB::table('T_WEB_Articoli') + ->select('idArticolo', 'Titolo', 'DataPubblicazione', 'Ean13', DB::raw('count(*) as total')) + ->groupBy('idArticolo', 'Titolo', 'DataPubblicazione', 'Ean13') + ->having('total', '>', 1) // Cerca solo i duplicati + ->get(); + + $response->setContent($duplicati); + return $response; + } catch (\Exception $e) { + return new Response('Error exporting articles: ' . $e->getMessage(), 500); + } } \ No newline at end of file diff --git a/resources/views/article_test.php b/resources/views/article_test.php new file mode 100644 index 00000000..35da7ac6 --- /dev/null +++ b/resources/views/article_test.php @@ -0,0 +1,39 @@ + + + + + + + Articoli + + + + +
+

Articoli

+ + + + + @if ($articoliVenduti->isEmpty()) + + + + @else + @foreach ($articoli as $articolo) + @if (isset($articolo->idArticolo)) + + + + + + + @endif + @endforeach + @endif + +
Nessun articolo trovato.
{{ $articolo->idArticolo }}{{ $articolo->Titolo }}{{ \Carbon\Carbon::parse($articolo->DataPubblicazione)->format('d/m/Y') }}{{ $articolo->totaleVenduto }}
+
+ + + \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 0388ea88..ba7d7c9f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -6407,3 +6407,4 @@ Route::get('/export-articles-sales', [ArticleController::class, 'exportArticlesS Route::get('/export-articles-sales-json', [ArticleController::class, 'exportArticlesSalesByJSON']); Route::get('/view-articles-sales', [ArticleController::class, 'showArticlesSales']); +Route::get('/article-test', [ArticleController::class, 'test']);