Upgrade to 3.5.1

This commit is contained in:
Bastian Allgeier
2021-01-19 12:20:38 +01:00
parent 8f55019e01
commit 99c36fa137
119 changed files with 2973 additions and 3707 deletions

View File

@@ -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) {

View File

@@ -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 '';
},
];

View File

@@ -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) {