From 293c2c535f2286336ac76811cb77c8f914d4304d Mon Sep 17 00:00:00 2001 From: TorstenS Date: Wed, 14 Oct 2020 09:33:09 +0200 Subject: [PATCH] =?UTF-8?q?Bericht=20f=C3=BCr=20alte=20Touren=20schreiben?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/Http/Controllers/TourController.php | 28 ++++++--- .../2020_09_30_082629_create_tours_table.php | 1 + motorradig/database/seeds/TourSeeder.php | 1 + .../resources/views/tour/edit_old.blade.php | 62 +++++++++++++++++++ .../resources/views/tour/show.blade.php | 5 -- .../resources/views/tour/show_old.blade.php | 29 ++------- 6 files changed, 88 insertions(+), 38 deletions(-) create mode 100644 motorradig/resources/views/tour/edit_old.blade.php diff --git a/motorradig/app/Http/Controllers/TourController.php b/motorradig/app/Http/Controllers/TourController.php index 35d18ea..ead2d4d 100644 --- a/motorradig/app/Http/Controllers/TourController.php +++ b/motorradig/app/Http/Controllers/TourController.php @@ -114,11 +114,17 @@ class TourController extends Controller $user=User::find($booking->user_id); array_push($users, $user); } + if($tour->startwith('tour', $tour) + ->with('users', $users) + ->with('creator', $creator); + } + return view('tour.show') - ->with('tour',$tour) + ->with('tour', $tour) ->with('users', $users) ->with('creator', $creator); - } /** @@ -130,7 +136,10 @@ class TourController extends Controller public function edit(Tour $tour) { error_log("Tour:edit"); - return view('tour.edit')->with('tour',$tour); + if ($tour->startwith('tour', $tour); + } + return view('tour.edit')->with('tour', $tour); } /** @@ -149,7 +158,6 @@ class TourController extends Controller [ 'tour_id' => 'required', 'name'=>'required|min:3', - 'beschreibung'=>'required', 'user_id'=>'required', 'bild'=>'mimes:jpg,jpeg,bmp,png,gif' ] @@ -177,12 +185,12 @@ class TourController extends Controller } $tour->name=$request->input('name'); - $tour->beschreibung=$request->input('beschreibung'); - $tour->start=$request->input('start'); - $tour->deadline=$request->input('deadline'); - $tour->max_participants=$request->input('max_participants'); - $tour->is_cancelled=$request->input('is_cancelled',false); - + if ($request->beschreibung) $request->input('beschreibung'); + if ($request->start) $tour->start=$request->input('start'); + if ($request->deadline) $tour->deadline=$request->input('deadline'); + if ($request->max_participants) $tour->max_participants=$request->input('max_participants'); + if ($request->is_cancelled) $tour->is_cancelled=$request->input('is_cancelled',false); + if ($request->bericht) $tour->bericht=$request->bericht; $tour->save(); return redirect('/tour'); diff --git a/motorradig/database/migrations/2020_09_30_082629_create_tours_table.php b/motorradig/database/migrations/2020_09_30_082629_create_tours_table.php index a137fde..e156a4c 100644 --- a/motorradig/database/migrations/2020_09_30_082629_create_tours_table.php +++ b/motorradig/database/migrations/2020_09_30_082629_create_tours_table.php @@ -22,6 +22,7 @@ class CreateToursTable extends Migration $table->date('start')->nullable(); $table->date('deadline')->nullable(); $table->boolean('is_cancelled')->default(false); + $table->text('bericht')->nullable(); $table->string('status')->default('FINDET STATT'); $table->timestamps(); }); diff --git a/motorradig/database/seeds/TourSeeder.php b/motorradig/database/seeds/TourSeeder.php index be54b33..0246142 100644 --- a/motorradig/database/seeds/TourSeeder.php +++ b/motorradig/database/seeds/TourSeeder.php @@ -19,6 +19,7 @@ class TourSeeder extends Seeder 'deadline' => Carbon::parse('2019-05-30'), 'is_cancelled' => false, 'max_participants' => 8, + 'bericht' => 'Wir hatten gutes Wetter, gute Stimmung, und alles war toll.', 'beschreibung' => 'Erster Versuch einer Moseltour.' ]); diff --git a/motorradig/resources/views/tour/edit_old.blade.php b/motorradig/resources/views/tour/edit_old.blade.php new file mode 100644 index 0000000..0ac17da --- /dev/null +++ b/motorradig/resources/views/tour/edit_old.blade.php @@ -0,0 +1,62 @@ +@extends('layouts.app') + +@section('content') +
+
+
+
+
{{ $tour->name }}
+ +
+ +
+ + @csrf + + @method('PUT') + + + +
+ + + +
+ +
+ + +
+ +
+ + + @if(file_exists (public_path ('img/tour/'.$tour->id.'.jpg'))) + + + + + @else + + @endif + + +
+ +
+ + +
+ +
Abbrechen
+ + +
+ +
+
+
+
+
+@endsection diff --git a/motorradig/resources/views/tour/show.blade.php b/motorradig/resources/views/tour/show.blade.php index b7f5278..ca9c656 100644 --- a/motorradig/resources/views/tour/show.blade.php +++ b/motorradig/resources/views/tour/show.blade.php @@ -59,11 +59,6 @@ - -
diff --git a/motorradig/resources/views/tour/show_old.blade.php b/motorradig/resources/views/tour/show_old.blade.php index b7f5278..8305c91 100644 --- a/motorradig/resources/views/tour/show_old.blade.php +++ b/motorradig/resources/views/tour/show_old.blade.php @@ -33,18 +33,12 @@
-
- - -
- @if(App\Tour::has_participant($tour->id, Auth::user()->id)) @else @endif - @if(file_exists (public_path ('img/tour/'.$tour->id.'.jpg'))) @@ -54,18 +48,15 @@ @endif -
- - -
- -
- - {{ old('max_participants') ?? count(\App\Tour::getBookings($tour->id)) }} +
+ +
-
@@ -73,14 +64,6 @@
Bearbeiten
Ok - @if(!App\Tour::has_participant($tour->id, Auth::user()->id)) - Teilnehmen - @else - Absagen - @endif - - -