Upgrade to 3.5.1
This commit is contained in:
@@ -106,6 +106,9 @@ return [
|
||||
return Str::upper($this->display);
|
||||
}
|
||||
},
|
||||
'format' => function () {
|
||||
return $this->props['format'] ?? ($this->time === false ? 'Y-m-d' : 'Y-m-d H:i:s');
|
||||
},
|
||||
'time' => function () {
|
||||
if ($this->time === false) {
|
||||
return false;
|
||||
@@ -127,10 +130,6 @@ return [
|
||||
return $this->toDatetime($this->value);
|
||||
},
|
||||
],
|
||||
'save' => function ($value) {
|
||||
$format = $this->time === false ? 'Y-m-d' : 'Y-m-d H:i:s';
|
||||
return $this->toContent($value, $format);
|
||||
},
|
||||
'validations' => [
|
||||
'date',
|
||||
'minMax' => function ($value) {
|
||||
|
@@ -1,6 +1,14 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'props' => [
|
||||
/**
|
||||
* Defines a custom format that is used when the field is saved
|
||||
*/
|
||||
'format' => function (string $format = null) {
|
||||
return $format;
|
||||
}
|
||||
],
|
||||
'methods' => [
|
||||
'toDatetime' => function ($value, string $format = 'Y-m-d H:i:s') {
|
||||
if ($timestamp = timestamp($value, $this->step)) {
|
||||
@@ -8,13 +16,13 @@ return [
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
'toContent' => function ($value, string $format = 'Y-m-d H:i:s') {
|
||||
if ($value !== null && $timestamp = strtotime($value)) {
|
||||
return date($format, $timestamp);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
]
|
||||
],
|
||||
'save' => function ($value) {
|
||||
if ($value !== null && $timestamp = strtotime($value)) {
|
||||
return date($this->format, $timestamp);
|
||||
}
|
||||
|
||||
return '';
|
||||
},
|
||||
];
|
||||
|
@@ -95,13 +95,13 @@ return [
|
||||
|
||||
return $this->notation === 24 ? 'HH:mm' : 'h:mm a';
|
||||
},
|
||||
'format' => function () {
|
||||
return $this->props['format'] ?? 'H:i:s';
|
||||
},
|
||||
'value' => function () {
|
||||
return $this->toDatetime($this->value, 'H:i:s');
|
||||
}
|
||||
],
|
||||
'save' => function ($value): string {
|
||||
return $this->toContent($value, 'H:i:s');
|
||||
},
|
||||
'validations' => [
|
||||
'time',
|
||||
'minMax' => function ($value) {
|
||||
|
Reference in New Issue
Block a user