From e6f3767e331f30c25a6d8adb402ea28e3e699505 Mon Sep 17 00:00:00 2001 From: TorstenS Date: Tue, 13 Oct 2020 10:20:48 +0200 Subject: [PATCH] View alter Touren, TourSeeder mit alter Tour, Verlinkung --- .../app/Http/Controllers/TourController.php | 17 ++- motorradig/app/Tour.php | 6 + motorradig/database/seeds/TourSeeder.php | 15 +- .../resources/views/tour/index.blade.php | 24 ++- .../resources/views/tour/index_old.blade.php | 38 +++++ .../resources/views/tour/show.blade.php | 2 + .../resources/views/tour/show_old.blade.php | 144 ++++++++++++++++++ motorradig/routes/web.php | 2 + 8 files changed, 238 insertions(+), 10 deletions(-) create mode 100644 motorradig/resources/views/tour/index_old.blade.php create mode 100644 motorradig/resources/views/tour/show_old.blade.php diff --git a/motorradig/app/Http/Controllers/TourController.php b/motorradig/app/Http/Controllers/TourController.php index 423271b..35d18ea 100644 --- a/motorradig/app/Http/Controllers/TourController.php +++ b/motorradig/app/Http/Controllers/TourController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers; use App\Tour; use App\Booking; use App\User; +use Carbon\Carbon; use Illuminate\Http\Request; use Illuminate\Http\File; use Illuminate\Support\Facades\Storage; @@ -22,7 +23,7 @@ class TourController extends Controller public function index() { error_log("Tour:index"); - $tours=Tour::all(); + $tours=Tour::where('start','>',Carbon::now())->get(); $participantCount=array(); foreach($tours as $tour) { $result = DB::select('select count(*) as cnt from bookings where tour_id=?', [$tour->id]); @@ -31,6 +32,19 @@ class TourController extends Controller return view('tour.index')->with('tours',$tours)->with('participantCount',$participantCount); } + public function index_old() + { + error_log("Tour:index_old"); + $tours=Tour::where('start','<',Carbon::now())->get(); + $participantCount=array(); + foreach($tours as $tour) { + $result = DB::select('select count(*) as cnt from bookings where tour_id=?', [$tour->id]); + $participantCount[$tour->id] = $result[0]->cnt; + } + return view('tour.index_old')->with('tours',$tours)->with('participantCount',$participantCount); + } + + /* @@ -206,4 +220,5 @@ class TourController extends Controller return redirect('/tour/'.$tour_id); } + } diff --git a/motorradig/app/Tour.php b/motorradig/app/Tour.php index 0b200fa..5721476 100644 --- a/motorradig/app/Tour.php +++ b/motorradig/app/Tour.php @@ -44,4 +44,10 @@ class Tour extends Model public static function cancel($tour_id, $user_id) { Booking::where('tour_id',$tour_id)->where('user_id',$user_id)->delete(); } + + public static function is_over($tour_id) { + $tour = Tour::find($tour_id); + if ($tour->start < Carbon::now()) return true; + return false; + } } diff --git a/motorradig/database/seeds/TourSeeder.php b/motorradig/database/seeds/TourSeeder.php index 11ad566..be54b33 100644 --- a/motorradig/database/seeds/TourSeeder.php +++ b/motorradig/database/seeds/TourSeeder.php @@ -12,12 +12,23 @@ class TourSeeder extends Seeder */ public function run() { + DB::table('tours')->insert([ + 'name' => 'Moseltour', + 'user_id' => 3, + 'start' => Carbon::parse('2019-06-11'), + 'deadline' => Carbon::parse('2019-05-30'), + 'is_cancelled' => false, + 'max_participants' => 8, + 'beschreibung' => 'Erster Versuch einer Moseltour.' + ]); + DB::table('tours')->insert([ 'name' => 'Eifeltour1', 'user_id' => 3, 'start' => Carbon::parse('2020-11-11'), 'deadline' => Carbon::parse('2020-11-01'), 'is_cancelled' => false, + 'max_participants' => 7, 'beschreibung' => 'Hier kann ein sehr langer Text stehen.' ]); @@ -27,6 +38,7 @@ class TourSeeder extends Seeder 'beschreibung' => 'Hier kann ein sehr langer Text stehen.', 'start' => Carbon::parse('2020-12-01'), 'deadline' => Carbon::parse('2020-11-02'), + 'max_participants' => 6, 'is_cancelled' => false, ]); @@ -36,10 +48,9 @@ class TourSeeder extends Seeder 'beschreibung' => 'Hier kann ein wirklich sehr langer Text stehen.

 

Es sind auch mehrere Abschnitte möglich.', 'start' => Carbon::parse('2020-12-15'), 'deadline' => Carbon::parse('2020-11-15'), + 'max_participants' => 5, 'is_cancelled' => true ]); } } - - diff --git a/motorradig/resources/views/tour/index.blade.php b/motorradig/resources/views/tour/index.blade.php index ce340e3..a5f58ff 100644 --- a/motorradig/resources/views/tour/index.blade.php +++ b/motorradig/resources/views/tour/index.blade.php @@ -2,8 +2,20 @@ @section('content')
-

Tourenplan

- Download +

Tourenplan: aktuelle Touren

+ + + +
@@ -26,14 +38,12 @@ @endforeach - - - -
+ + @if(Auth::user()->role=="ADMIN" or Auth::user()->rolde=="MEMBER") @endif diff --git a/motorradig/resources/views/tour/index_old.blade.php b/motorradig/resources/views/tour/index_old.blade.php new file mode 100644 index 0000000..35f485a --- /dev/null +++ b/motorradig/resources/views/tour/index_old.blade.php @@ -0,0 +1,38 @@ +@extends('layouts.app') + +@section('content') + +@endsection diff --git a/motorradig/resources/views/tour/show.blade.php b/motorradig/resources/views/tour/show.blade.php index e78be37..b7f5278 100644 --- a/motorradig/resources/views/tour/show.blade.php +++ b/motorradig/resources/views/tour/show.blade.php @@ -79,6 +79,8 @@ Absagen @endif + +
diff --git a/motorradig/resources/views/tour/show_old.blade.php b/motorradig/resources/views/tour/show_old.blade.php new file mode 100644 index 0000000..b7f5278 --- /dev/null +++ b/motorradig/resources/views/tour/show_old.blade.php @@ -0,0 +1,144 @@ +@extends('layouts.app') + +@section('content') +
+
+
+
+
{{ $tour->name }}
+ +
+ +
+ @csrf + +
+ + + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ + @if(App\Tour::has_participant($tour->id, Auth::user()->id)) + + @else + + @endif + + + @if(file_exists (public_path ('img/tour/'.$tour->id.'.jpg'))) + + + + + @else + + @endif + +
+ + +
+ + + +
+ +
+ + +
Bearbeiten
+ Ok + + @if(!App\Tour::has_participant($tour->id, Auth::user()->id)) + Teilnehmen + @else + Absagen + @endif + + + +
+ +
+
+
+ +
+
+
Teilnehmer
+ +
+ +
    + @foreach($users as $user) +
  • {{ $user->name }}   + @if(Auth::user()->role=="ADMIN") + (X) + @endif +
  • + @endforeach +
+ + +
+
+
+ +
+
+ + + + + + +@endsection diff --git a/motorradig/routes/web.php b/motorradig/routes/web.php index 694d1a7..194ab3a 100644 --- a/motorradig/routes/web.php +++ b/motorradig/routes/web.php @@ -43,7 +43,9 @@ Route::get('/admin/edit_home', 'AdminController@edit_home'); Route::get('/admin/edit_activities', 'AdminController@edit_activities'); Route::post('/admin/store_activities', 'AdminController@store_activities'); +Route::get('/tour/index_old', 'TourController@index_old'); Route::resource('/tour', TourController::class); + Route::get('/tour/{tour_id}/join', 'TourController@join'); Route::get('/tour/{tour_id}/cancelBooking', 'TourController@cancelBooking'); Route::get('/tour/{tour_id}/cancelBookingAdmin/{user_id}', 'TourController@cancelBookingAdmin');