From ea373d04c7c0ed6065f9080cd085e0099c112633 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20St=C3=B6ckel?= Date: Wed, 30 Dec 2020 01:34:00 +0100 Subject: [PATCH] [REWE] Show informations about markets --- app/Http/Controllers/ReweController.php | 19 +++++ ...11718_add_user_shop_index_to_rewe_bons.php | 21 ++++++ resources/views/rewe_ebon/overview.blade.php | 6 +- .../views/rewe_ebon/receipt_details.blade.php | 6 +- resources/views/rewe_ebon/shop.blade.php | 70 +++++++++++++++++++ routes/web.php | 2 + 6 files changed, 120 insertions(+), 4 deletions(-) create mode 100644 database/migrations/2020_12_30_011718_add_user_shop_index_to_rewe_bons.php create mode 100644 resources/views/rewe_ebon/shop.blade.php diff --git a/app/Http/Controllers/ReweController.php b/app/Http/Controllers/ReweController.php index a4bf661..d4898d5 100644 --- a/app/Http/Controllers/ReweController.php +++ b/app/Http/Controllers/ReweController.php @@ -5,6 +5,7 @@ use App\ReweBon; use App\ReweBonPosition; use App\ReweProduct; +use App\ReweShop; use App\User; use App\UserSettings; use Illuminate\Contracts\Support\Renderable; @@ -217,4 +218,22 @@ public function showProduct(int $id): Renderable { ]); } + public function showShop(int $id): Renderable { + $shop = ReweShop::findOrFail($id); + + $history = ReweBon::where('user_id', Auth::user()->id) + ->where('shop_id', $shop->id) + ->orderBy('timestamp_bon', 'DESC') + ->select(['id', 'cashregister_nr', 'paymentmethod', 'user_id', 'shop_id', 'timestamp_bon', 'total']) + ->paginate(7); + + $countOther = ReweBon::where('shop_id', $shop->id)->select(['user_id'])->groupBy(['user_id'])->count(); + + return view('rewe_ebon.shop', [ + 'shop' => $shop, + 'history' => $history, + 'countOther' => $countOther - 1 + ]); + } + } diff --git a/database/migrations/2020_12_30_011718_add_user_shop_index_to_rewe_bons.php b/database/migrations/2020_12_30_011718_add_user_shop_index_to_rewe_bons.php new file mode 100644 index 0000000..97b3cc6 --- /dev/null +++ b/database/migrations/2020_12_30_011718_add_user_shop_index_to_rewe_bons.php @@ -0,0 +1,21 @@ +index(['user_id', 'shop_id']); + }); + } + + + public function down(): void { + Schema::table('rewe_bons', function(Blueprint $table) { + $table->dropIndex(['user_id', 'shop_id']); + }); + } +} diff --git a/resources/views/rewe_ebon/overview.blade.php b/resources/views/rewe_ebon/overview.blade.php index 087cb53..d67aada 100644 --- a/resources/views/rewe_ebon/overview.blade.php +++ b/resources/views/rewe_ebon/overview.blade.php @@ -274,8 +274,10 @@ class="mdi mdi-trending-up" {{$bon->timestamp_bon->format('d.m.Y H:i')}} - {{$bon->shop->name}}
- {{$bon->shop->zip}} {{$bon->shop->city}} + + Markt {{$bon->shop->id}}
+ in {{$bon->shop->zip}} {{$bon->shop->city}} +
{{$bon->cashregister_nr}} {{$bon->paymentmethod}} diff --git a/resources/views/rewe_ebon/receipt_details.blade.php b/resources/views/rewe_ebon/receipt_details.blade.php index 24b36ce..c7fde8b 100644 --- a/resources/views/rewe_ebon/receipt_details.blade.php +++ b/resources/views/rewe_ebon/receipt_details.blade.php @@ -12,8 +12,10 @@ {{__('receipts.market')}} - {{$bon->shop->name}}
- {{$bon->shop->zip}} {{$bon->shop->city}} + + Markt {{$bon->shop->id}}
+ in {{$bon->shop->zip}} {{$bon->shop->city}} +
diff --git a/resources/views/rewe_ebon/shop.blade.php b/resources/views/rewe_ebon/shop.blade.php new file mode 100644 index 0000000..6319744 --- /dev/null +++ b/resources/views/rewe_ebon/shop.blade.php @@ -0,0 +1,70 @@ +@extends('layout.app') + +@section('title') REWE Markt {{$shop->id}} in {{$shop->zip}} {{$shop->city}} @endsection + +@section('content') +
+
+
+
+ + + + + + + + + + + + @foreach($history as $receipt) + + + + + + + + @endforeach + +
ZeitpunktKasseZahlungsmethodeBetrag
{{$receipt->timestamp_bon->format('d.m.Y H:i')}}{{$receipt->cashregister_nr}}{{$receipt->paymentmethod}}{{number_format($receipt->total, 2, ",", ".")}} €Details
+ {{$history->links()}} +
+
+
+
+
+
+

Einkaufsfreunde

+ @if($countOther == 0) +

Du bist bisher der einzige KStats-Nutzer, welcher in diesem REWE-Markt einkaufen war! +

+ @elseif($countOther > 1) +

Du hast einen Einkaufsfreund, denn neben dir hat ein weiterer KStats-Nutzer in + diesem + REWE-Markt eingekauft.

+ @else +

Dieser REWE-Markt scheint beliebt zu sein. Neben dir haben hier bereits {{$countOther}} + andere KStats-Nutzer eingekauft!

+ @endif +
+
+ +
+
+

{{$shop->name}}

+ {{$shop->address}}
+ {{$shop->zip}} {{$shop->city}}
+
+ @isset($shop->phone) + {{$shop->phone}}
+ @endisset + @isset($shop->opening_hours) + {{$shop->opening_hours}}
+ @endisset +
+
+
+
+@endsection \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 380a853..053bd94 100644 --- a/routes/web.php +++ b/routes/web.php @@ -70,6 +70,8 @@ ->name('download_raw_rewe_receipt'); Route::get('/rewe/product/{id}', [ReweController::class, 'showProduct']) ->name('rewe.product'); + Route::get('/rewe/shop/{id}', [ReweController::class, 'showShop']) + ->name('rewe.shop'); Route::get('/crowdsourcing/rewe/', [CrowdsourceController::class, 'renderRewe']) ->name('crowdsourcing_rewe');