From 368365d568f9410c85e41f8cc0bc0067ccf9635d Mon Sep 17 00:00:00 2001 From: Mateja Date: Thu, 3 Dec 2020 23:44:45 +0100 Subject: Use d.m.Y. instead of Y-m-d --- app/Models/Reservation.php | 29 +++++++++++++++++++++++++++++ public/js/activities.js | 2 +- resources/views/pages/reserve.blade.php | 23 +++++++++++++++++++---- 3 files changed, 49 insertions(+), 5 deletions(-) diff --git a/app/Models/Reservation.php b/app/Models/Reservation.php index 021f3d6..733571e 100644 --- a/app/Models/Reservation.php +++ b/app/Models/Reservation.php @@ -5,7 +5,36 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Carbon\Carbon; + class Reservation extends Model { use HasFactory; + + public function getFromTimeAttribute() { + return Carbon::parse($this->attributes['fromTime'])->format('d.m.Y. H:i'); + } + + public function setFromTimeAttribute($value) { + $this->attributes['fromTime'] = Carbon::createFromFormat('d.m.Y. H:i', $value)->toDateTimeString(); + } + + public function getToTimeAttribute() { + return Carbon::parse($this->attributes['toTime'])->format('d.m.Y. H:i'); + } + + public function setToTimeAttribute($value) { + $this->attributes['toTime'] = Carbon::createFromFormat('d.m.Y. H:i', $value)->toDateTimeString(); + } + + // I am quite sure this not working is a bug. + //protected function serializeDate(\DateTimeInterface $date) + //{ + //return $date->format('d.m.Y. H:i'); + //} + + protected $casts = [ + 'fromTime' => 'datetime:d.m.Y. H:i', + 'toTime' => 'datetime:d.m.Y. H:i', + ]; } diff --git a/public/js/activities.js b/public/js/activities.js index 4d46374..eacf4d3 100644 --- a/public/js/activities.js +++ b/public/js/activities.js @@ -9,7 +9,7 @@ jQuery(document).ready(fillTable); function fillTable() { tableData = jQuery('table#ajax-table>tbody').first(); - tableData.html('Loading...'); + tableData.html('Loading...'); sign = jQuery('select#call-sign').first().val(); diff --git a/resources/views/pages/reserve.blade.php b/resources/views/pages/reserve.blade.php index fc7f16f..823e8b9 100644 --- a/resources/views/pages/reserve.blade.php +++ b/resources/views/pages/reserve.blade.php @@ -42,7 +42,7 @@
- + @error('sdate')
{{ $message }}
@enderror @@ -50,7 +50,7 @@
- + @error('stime')
{{ $message }}
@enderror @@ -59,7 +59,7 @@
- + @error('edate')
{{ $message }}
@enderror @@ -67,7 +67,7 @@
- + @error('etime')
{{ $message }}
@enderror @@ -147,6 +147,21 @@ @endsection() +@section('styles') + +@endsection + @section('scripts') + + @endsection -- cgit v1.2.3