Date
class Date implements Stringable
Traits
Properties
| static protected array | $macros | The registered string macros. |
from Macroable |
| protected string|null | $format | The format of the date. |
|
| protected array | $constraints | The constraints for the date rule. |
Methods
Apply the callback if the given "value" is (or resolves to) truthy.
Apply the callback if the given "value" is (or resolves to) falsy.
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Ensure the date is before today.
Ensure the date is after today.
Ensure the date is before or equal to today.
Ensure the date is after or equal to today.
Ensure the date is now or in the future.
Ensure the date is on or before the specified date or date field.
Ensure the date is on or after the given date or date field.
Ensure the date is between two dates or date fields.
Ensure the date is between or equal to two dates or date fields.
Convert the rule to a validation string.
Flush all static state.
Details
in
Conditionable at line 23
mixed
when(mixed $value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) truthy.
in
Conditionable at line 56
mixed
unless(mixed $value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) falsy.
in
Macroable at line 28
static void
macro(string $name, callable|object $macro)
Register a custom macro.
Boot-only. Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.
in
Macroable at line 41
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
Boot-only. Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.
in
Macroable at line 57
static bool
hasMacro(string $name)
Check if macro is registered.
in
Macroable at line 68
static void
flushMacros()
Flush the existing macros.
Boot or tests only. Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.
in
Macroable at line 78
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
in
Macroable at line 103
mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
at line 31
Date
format(string $format)
Ensure the date has the given format.
at line 41
Date
beforeToday()
Ensure the date is before today.
at line 49
Date
afterToday()
Ensure the date is after today.
at line 57
Date
todayOrBefore()
Ensure the date is before or equal to today.
at line 65
Date
todayOrAfter()
Ensure the date is after or equal to today.
at line 73
Date
past()
Ensure the date is in the past.
at line 81
Date
future()
Ensure the date is in the future.
at line 89
Date
nowOrPast()
Ensure the date is now or in the past.
at line 97
Date
nowOrFuture()
Ensure the date is now or in the future.
at line 105
Date
before(DateTimeInterface|string $date)
Ensure the date is before the given date or date field.
at line 113
Date
after(DateTimeInterface|string $date)
Ensure the date is after the given date or date field.
at line 121
Date
beforeOrEqual(DateTimeInterface|string $date)
Ensure the date is on or before the specified date or date field.
at line 129
Date
afterOrEqual(DateTimeInterface|string $date)
Ensure the date is on or after the given date or date field.
at line 137
Date
between(DateTimeInterface|string $from, DateTimeInterface|string $to)
Ensure the date is between two dates or date fields.
at line 145
Date
betweenOrEqual(DateTimeInterface|string $from, DateTimeInterface|string $to)
Ensure the date is between or equal to two dates or date fields.
at line 153
protected Date
addRule(array|string $rules)
Add custom rules to the validation rules array.
at line 163
protected string
formatDate(DateTimeInterface|string $date)
Format the date for the validation rule.
at line 173
string
__toString()
Convert the rule to a validation string.
at line 184
static void
flushState()
Flush all static state.