Datepicker from CDN on TourEdit Page
This commit is contained in:
parent
cb07013fde
commit
af73b49cfa
4 changed files with 64 additions and 6 deletions
|
|
@ -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->start<Carbon::now()) {
|
||||
$tour->start = 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->start<Carbon::now()) {
|
||||
return view('tour.edit_old')->with('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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vanillajs-datepicker@1.1.2/dist/css/datepicker.min.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/vanillajs-datepicker@1.1.2/dist/js/datepicker.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/vanillajs-datepicker@1.1.2/dist/js/locales/de.js"></script>
|
||||
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-8">
|
||||
|
|
@ -9,6 +13,7 @@
|
|||
|
||||
<div class="card-body">
|
||||
|
||||
|
||||
<form style="background-color: #fff;" class="text-dark" method="post" action="/tour/{{$tour->id}}" enctype="multipart/form-data">
|
||||
|
||||
@csrf
|
||||
|
|
@ -25,7 +30,7 @@
|
|||
|
||||
<div class="form-group" style="display:flex;">
|
||||
<label class="ml-2 mt-3" style="width:180px; text-align:left;font-size:18px;" for="name">Start:</label>
|
||||
<input class="mt-3 mr-2 form-control input-sm" type="text" id="start" name="start" value="{{ old('start') ?? $tour->start }}" required >
|
||||
<input class="mt-3 mr-2 form-control input-sm" type="text" id="start" name="start" value="{{ $tour->start }}" required >
|
||||
</div>
|
||||
|
||||
<div class="form-group" style="display:flex;">
|
||||
|
|
@ -82,4 +87,21 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const elem = document.querySelector('input[name="start"]');
|
||||
const datepicker_start = new Datepicker(elem, {
|
||||
'autohide':true,
|
||||
'format':'dd.mm.yyyy',
|
||||
'language': 'de'
|
||||
});
|
||||
|
||||
const elem2 = document.querySelector('input[name="deadline"]');
|
||||
const datepicker_deadline = new Datepicker(elem2, {
|
||||
'autohide':true,
|
||||
'format':'dd.mm.yyyy',
|
||||
'language':'de'
|
||||
});
|
||||
</script>
|
||||
|
||||
@endsection
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
<div class="mt-1" style="display:flex;">
|
||||
<label class="ml-2" style="width:180px; text-align:left;font-size:18px;" for="name">Anmeldeschluss:</label>
|
||||
<input class="mr-1 form-control" type="text" id="anmeldeschluss" style="font-size:16px;" name="start" value="{{ old('anmeldeschluss') ?? $tour->deadline }}" readonly >
|
||||
<input class="mr-1 form-control" type="text" id="anmeldeschluss" style="font-size:16px;" name="deadline" value="{{ old('anmeldeschluss') ?? $tour->deadline }}" readonly >
|
||||
</div>
|
||||
|
||||
<div class="mt-1" style="display:flex;">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue