Date
class Date implements Stringable (View source)
Traits
Properties
static protected array | $macros | The registered string macros. |
from Macroable |
protected | $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 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.
Format the date for the validation rule.
Convert the rule to a validation string.
Details
$this|TWhenReturnType
when($value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) truthy.
$this|TUnlessReturnType
unless($value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) falsy.
static void
macro(string $name, object|callable $macro)
Register a custom macro.
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
static bool
hasMacro(string $name)
Checks if macro is registered.
static void
flushMacros()
Flush the existing macros.
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
Date
format(string $format)
Ensure the date has the given format.
Date
beforeToday()
Ensure the date is before today.
Date
afterToday()
Ensure the date is after today.
Date
todayOrBefore()
Ensure the date is before or equal to today.
Date
todayOrAfter()
Ensure the date is after or equal to today.
Date
before(DateTimeInterface|string $date)
Ensure the date is before the given date or date field.
Date
after(DateTimeInterface|string $date)
Ensure the date is after the given date or date field.
Date
beforeOrEqual(DateTimeInterface|string $date)
Ensure the date is on or before the specified date or date field.
Date
afterOrEqual(DateTimeInterface|string $date)
Ensure the date is on or after the given date or date field.
Date
between(DateTimeInterface|string $from, DateTimeInterface|string $to)
Ensure the date is between two dates or date fields.
Date
betweenOrEqual(DateTimeInterface|string $from, DateTimeInterface|string $to)
Ensure the date is between or equal to two dates or date fields.
protected Date
addRule(array|string $rules)
Add custom rules to the validation rules array.
protected string
formatDate(DateTimeInterface|string $date)
Format the date for the validation rule.
string
__toString()
Convert the rule to a validation string.