aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorMateja <mail@matejamaric.com>2020-12-03 23:44:45 +0100
committerMateja <mail@matejamaric.com>2020-12-03 23:44:45 +0100
commit368365d568f9410c85e41f8cc0bc0067ccf9635d (patch)
tree23f80852e912ac98c4533752911d654707cb80bd /app
parent5bffb9ddd5fc8a236f8f8ce1d27224b3031711dc (diff)
downloadyota-laravel-368365d568f9410c85e41f8cc0bc0067ccf9635d.tar.gz
yota-laravel-368365d568f9410c85e41f8cc0bc0067ccf9635d.zip
Use d.m.Y. instead of Y-m-dv1.0.1
Diffstat (limited to 'app')
-rw-r--r--app/Models/Reservation.php29
1 files changed, 29 insertions, 0 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',
+ ];
}