diff --git a/motorradig/app/Http/Controllers/TourController.php b/motorradig/app/Http/Controllers/TourController.php index d67d147..c29fc78 100644 --- a/motorradig/app/Http/Controllers/TourController.php +++ b/motorradig/app/Http/Controllers/TourController.php @@ -88,8 +88,8 @@ class TourController extends Controller $tour->name=$request->input('name'); $tour->user_id=$request->input('user_id'); $tour->beschreibung=$request->input('beschreibung'); - $tour->start=$request->input('start'); - $tour->deadline=$request->input('deadline'); + $tour->start=Tour::toDBDate($request->input('start')); + $tour->deadline=Tour::toDBDate($request->input('deadline')); $tour->max_participants=$request->input('max_participants'); $tour->is_cancelled=$request->input('is_cancelled',false); $tour->save(); @@ -115,12 +115,16 @@ class TourController extends Controller array_push($users, $user); } if($tour->startstart = Tour::toGermanDate($tour->start); + $tour->deadline = Tour::toGermanDate($tour->deadline); return view('tour.show_old') ->with('tour', $tour) ->with('users', $users) ->with('creator', $creator); } + $tour->start = Tour::toGermanDate($tour->start); + $tour->deadline = Tour::toGermanDate($tour->deadline); return view('tour.show') ->with('tour', $tour) ->with('users', $users) @@ -139,6 +143,10 @@ class TourController extends Controller if ($tour->startwith('tour', $tour); } + + $tour->start = Tour::toGermanDate($tour->start); + $tour->deadline = Tour::toGermanDate($tour->deadline); + return view('tour.edit')->with('tour', $tour); } @@ -187,8 +195,8 @@ class TourController extends Controller $tour->name=$request->input('name'); if ($request->beschreibung) $tour->beschreibung=$request->input('beschreibung'); - if ($request->start) $tour->start=$request->input('start'); - if ($request->deadline) $tour->deadline=$request->input('deadline'); + if ($request->start) $tour->start=Tour::toDBDate($request->input('start')); + if ($request->deadline) $tour->deadline=Tour::toDBDate($request->input('deadline')); if ($request->max_participants) $tour->max_participants=$request->input('max_participants'); $tour->is_cancelled= ($request->has('is_cancelled')); if ($request->bericht) $tour->bericht=$request->bericht; diff --git a/motorradig/app/Tour.php b/motorradig/app/Tour.php index 5721476..022d89d 100644 --- a/motorradig/app/Tour.php +++ b/motorradig/app/Tour.php @@ -50,4 +50,32 @@ class Tour extends Model if ($tour->start < Carbon::now()) return true; return false; } + + public static function toGermanDate($engDate) + { + error_log("to german Date:"); + error_log($engDate); + $values = explode("-", $engDate); + $year = $values[0]; + $month = $values[1]; + $day = $values[2]; + + return $day.".".$month.".".$year; + } + + public static function toDBDate($deDate) + { + if (!$deDate) return ""; + + $values = explode(" ", $deDate); + + $year = explode(".",$values[0])[2]; + $month = explode(".",$values[0])[1]; + $day = explode(".", $values[0])[0]; + + $dbDate=$year . "-" . $month . "-" . $day; + //Log::info("deDate=".$deDate." converted to:".$dbDate); + + return $dbDate; + } } diff --git a/motorradig/resources/views/tour/edit.blade.php b/motorradig/resources/views/tour/edit.blade.php index 14f1509..e3403ee 100644 --- a/motorradig/resources/views/tour/edit.blade.php +++ b/motorradig/resources/views/tour/edit.blade.php @@ -1,6 +1,10 @@ @extends('layouts.app') @section('content') + + + +
@@ -9,6 +13,7 @@
+
@csrf @@ -25,7 +30,7 @@
- +
@@ -82,4 +87,21 @@
+ + + @endsection diff --git a/motorradig/resources/views/tour/show.blade.php b/motorradig/resources/views/tour/show.blade.php index ec3cae8..e5c8a96 100644 --- a/motorradig/resources/views/tour/show.blade.php +++ b/motorradig/resources/views/tour/show.blade.php @@ -30,7 +30,7 @@
- +