From e9f629db90085b911c5f4bbfa18b3e5b5fb5ebf1 Mon Sep 17 00:00:00 2001 From: TorstenS Date: Tue, 6 Oct 2020 08:54:14 +0200 Subject: [PATCH] Started work on Tour Booking --- .../Http/Controllers/BookingController.php | 85 ------------------- .../app/Http/Controllers/TourController.php | 13 +++ motorradig/app/Tour.php | 6 ++ .../views/tour/index_bookings.blade.php | 31 +++++++ .../resources/views/tour/show.blade.php | 4 + 5 files changed, 54 insertions(+), 85 deletions(-) delete mode 100644 motorradig/app/Http/Controllers/BookingController.php create mode 100644 motorradig/resources/views/tour/index_bookings.blade.php diff --git a/motorradig/app/Http/Controllers/BookingController.php b/motorradig/app/Http/Controllers/BookingController.php deleted file mode 100644 index 078761c..0000000 --- a/motorradig/app/Http/Controllers/BookingController.php +++ /dev/null @@ -1,85 +0,0 @@ -with('tours',$tours); } + + public function index_bookings($tour_id) + { + $tour=Tour::find($tour_id); + $bookings=array(); + foreach($tour->getBookings($tour_id) as $booking) { + array_push($bookings,$booking); + } + error_log("Tour:index_bookings, tour_id=".$tour->id); + return view('tour.index_bookings')->with('tour',$tour)->with('bookings',$bookings); + } + + /** * Show the form for creating a new resource. * diff --git a/motorradig/app/Tour.php b/motorradig/app/Tour.php index 794b9e1..197f33b 100644 --- a/motorradig/app/Tour.php +++ b/motorradig/app/Tour.php @@ -9,4 +9,10 @@ class Tour extends Model protected $fillable = [ 'id', 'name', 'beschreibung','user_id','start','deadline' ]; + + public static function getBookings($tour_id) { + error_log("getBookings for tour_id: ".$tour_id); + $bookings=Booking::where('tour_id',$tour_id)->get(); + return $bookings; + } } diff --git a/motorradig/resources/views/tour/index_bookings.blade.php b/motorradig/resources/views/tour/index_bookings.blade.php new file mode 100644 index 0000000..c3b3743 --- /dev/null +++ b/motorradig/resources/views/tour/index_bookings.blade.php @@ -0,0 +1,31 @@ +@extends('layouts.app') + +@section('content') +
+

Teilnehmer

+ +
+ . + + + + +
+ @if(Auth::user()->role=="ADMIN" or Auth::user()->rolde=="MEMBER") + + @endif + +
+@endsection diff --git a/motorradig/resources/views/tour/show.blade.php b/motorradig/resources/views/tour/show.blade.php index f131f43..27f3d93 100644 --- a/motorradig/resources/views/tour/show.blade.php +++ b/motorradig/resources/views/tour/show.blade.php @@ -47,6 +47,10 @@ +
+ + {{ old('max_participants') ?? count(\App\Tour::getBookings($tour->id)) }} +