trait HasCasts

Constants

private PRIMITIVE_CAST_TYPES

The built-in request cast types.

Methods

array
casts()

Get the casts for the validated request input.

array
castValidatedInput(array $input)

Cast the validated request input.

mixed
castNativeInput(string $castType, string|null $primitiveCastType, string|null $argumentString, mixed $value)

Cast one input through a primitive or enum declaration.

mixed
castPrimitiveInput(string $castType, string|null $argumentString, mixed $value)

Cast one input through a primitive declaration.

void
ensureValidDecimalScale(string|null $scale, string $input)

Ensure the decimal cast has a valid scale.

resolveRequestCaster(string $castType, array $arguments, string $input)

Resolve a custom request caster.

float
fromFloat(mixed $value)

Decode the given float.

string
asDecimal(mixed $value, int $decimals)

Return a decimal as a string.

object
asObject(mixed $value)

Decode the given JSON value as an object.

CarbonInterface
asDate(mixed $value, string|null $format = null)

Return a date with its time set to the start of the day.

CarbonInterface
asDateTime(mixed $value, string|null $format = null)

Return a date-time instance.

Details

at line 58
protected array casts()

Get the casts for the validated request input.

Return Value

array

at line 69
protected array castValidatedInput(array $input)

Cast the validated request input.

Parameters

array $input

Return Value

array

at line 345
protected mixed castNativeInput(string $castType, string|null $primitiveCastType, string|null $argumentString, mixed $value)

Cast one input through a primitive or enum declaration.

Parameters

string $castType
string|null $primitiveCastType
string|null $argumentString
mixed $value

Return Value

mixed

at line 373
protected mixed castPrimitiveInput(string $castType, string|null $argumentString, mixed $value)

Cast one input through a primitive declaration.

Parameters

string $castType
string|null $argumentString
mixed $value

Return Value

mixed

at line 395
protected void ensureValidDecimalScale(string|null $scale, string $input)

Ensure the decimal cast has a valid scale.

Parameters

string|null $scale
string $input

Return Value

void

at line 409
protected CastsRequestInput resolveRequestCaster(string $castType, array $arguments, string $input)

Resolve a custom request caster.

Parameters

string $castType
array $arguments
string $input

Return Value

CastsRequestInput

at line 427
protected float fromFloat(mixed $value)

Decode the given float.

Parameters

mixed $value

Return Value

float

at line 444
protected string asDecimal(mixed $value, int $decimals)

Return a decimal as a string.

Parameters

mixed $value
int $decimals

Return Value

string

at line 456
protected object asObject(mixed $value)

Decode the given JSON value as an object.

Parameters

mixed $value

Return Value

object

at line 471
protected CarbonInterface asDate(mixed $value, string|null $format = null)

Return a date with its time set to the start of the day.

Parameters

mixed $value
string|null $format

Return Value

CarbonInterface

at line 479
protected CarbonInterface asDateTime(mixed $value, string|null $format = null)

Return a date-time instance.

Parameters

mixed $value
string|null $format

Return Value

CarbonInterface