QR_code_generator/app/Models/Objects/Values/DatetimeValue.php

28 lines
696 B
PHP

<?php
namespace App\Models\Objects\Values;
use Carbon\Carbon;
class DatetimeValue extends Value {
protected $table = 'field_datetime_values';
protected $dates = [
'value'
];
public function get() {
return $this->value ? $this->value->toIso8601String() : null;
}
public function set($value): bool {
return parent::set($value);
}
public static function applyFilter($query, $value) {
$value = collect($value)->map(function($value) {
return $value ? Carbon::create($value)->format('Y-m-d H:i') : null;
});
parent::applyFilter($query, ($value->count() === 2) ? $value->all() : $value->first());
}
}