PHP Трейт Esensi\Model\Traits\JugglingModelTrait

См. также: Esensi\Model\Contracts\JugglingModelInterface
Автор: Diego Caprioli ([email protected])
Автор: Daniel LaBarge ([email protected])
Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
$juggling boolean Whether the model is type juggling attributes or not.

Открытые методы

Метод Описание
__get ( string $key ) : mixed Dynamically retrieve attributes on the model.
__set ( string $key, mixed $value ) Dynamically set attributes on the model.
addJugglable ( string $attribute, string $type ) Add an attribute to the jugglable array.
attributesToArray ( ) : array Override attributesToArray() Eloquent Model method, to type juggle first, and then call the parent method.
buildJuggleMethod ( string $type ) : string Build the method name that the type normalizes to.
checkJuggleType ( string $type ) : boolean Checks whether the type is a type that can be juggled to.
getJugglable ( ) : array Get the juggable attributes.
getJuggleType ( string $attribute ) : string Gets the type that the attribute will be casted to.
getJuggling ( ) : boolean Returns whether or not the model will juggle attributes.
isJugglable ( string $attribute ) : boolean Returns whether the attribute is type jugglable.
isJuggleType ( string $type ) : boolean Returns whether the type is a type that can be juggled to.
juggle ( mixed $value, string $type ) : mixed Cast the value to the attribute's type as specified in the juggable array.
juggleArray ( mixed $value ) : array Returns the value as an array.
juggleAttribute ( string $attribute, string $value ) Casts a value to the coresponding attribute type and sets it on the attributes array of this model.
juggleAttributes ( ) Juggles all attributes that are configured to be juggled.
juggleBoolean ( mixed $value ) : boolean Returns the value as a boolean.
juggleDate ( mixed $value ) : Carbon\Carbon\Carbon Returns the value as a Carbon instance.
juggleDateTime ( mixed $value ) : string Returns a string formated as ISO standard of 0000-00-00 00:00:00.
juggleFloat ( mixed $value ) : float Returns the value as a float.
juggleInteger ( mixed $value ) : integer Returns the value as an integer.
juggleNull ( mixed $value ) : mixed | null Casts to null on empty.
juggleString ( mixed $value ) : string Returns the value as a string.
juggleTimestamp ( mixed $value ) : integer Returns the date as a Unix timestamp.
mergeJugglable ( array $attributes ) Merge an array of attributes with the jugglable array.
removeJugglable ( mixed $attributes ) Remove an attribute or several attributes from the jugglable array.
setJugglable ( array $attributes ) Set the jugglable attributes.
setJuggling ( $value ) Set whether or not the model will juggle attributes.

Защищенные методы

Метод Описание
getDynamicJuggle ( string $key, mixed $value ) : mixed If juggling is active, it returns the juggleAttribute.
juggleType ( mixed $value, string $type ) : mixed Casts the value to the type. Possibles types are: boolean, integer, float, string, array, object, null.
setDynamicJuggle ( string $key, mixed $value ) If juggling is active, it sets the attribute in the model by type juggling the value first.

Описание методов

__get() публичный Метод

Dynamically retrieve attributes on the model.
public __get ( string $key ) : mixed
$key string
Результат mixed

__set() публичный Метод

Dynamically set attributes on the model.
public __set ( string $key, mixed $value )
$key string
$value mixed

addJugglable() публичный Метод

Add an attribute to the jugglable array.
public addJugglable ( string $attribute, string $type )
$attribute string
$type string

attributesToArray() публичный Метод

Override attributesToArray() Eloquent Model method, to type juggle first, and then call the parent method.
См. также: Illuminate\Database\Eloquent\Model::attributestoArray()
public attributesToArray ( ) : array
Результат array

buildJuggleMethod() публичный Метод

Build the method name that the type normalizes to.
public buildJuggleMethod ( string $type ) : string
$type string to cast
Результат string

checkJuggleType() публичный Метод

Checks whether the type is a type that can be juggled to.
public checkJuggleType ( string $type ) : boolean
$type string to cast
Результат boolean

getDynamicJuggle() защищенный Метод

If not it just returns the value as it was passed.
protected getDynamicJuggle ( string $key, mixed $value ) : mixed
$key string
$value mixed
Результат mixed

getJugglable() публичный Метод

Get the juggable attributes.
public getJugglable ( ) : array
Результат array

getJuggleType() публичный Метод

Gets the type that the attribute will be casted to.
public getJuggleType ( string $attribute ) : string
$attribute string
Результат string

getJuggling() публичный Метод

Returns whether or not the model will juggle attributes.
public getJuggling ( ) : boolean
Результат boolean

isJugglable() публичный Метод

Returns whether the attribute is type jugglable.
public isJugglable ( string $attribute ) : boolean
$attribute string name
Результат boolean

isJuggleType() публичный Метод

Returns whether the type is a type that can be juggled to.
public isJuggleType ( string $type ) : boolean
$type string to cast
Результат boolean

juggle() публичный Метод

Cast the value to the attribute's type as specified in the juggable array.
public juggle ( mixed $value, string $type ) : mixed
$value mixed
$type string
Результат mixed

juggleArray() публичный Метод

Returns the value as an array.
public juggleArray ( mixed $value ) : array
$value mixed
Результат array

juggleAttribute() публичный Метод

Casts a value to the coresponding attribute type and sets it on the attributes array of this model.
public juggleAttribute ( string $attribute, string $value )
$attribute string
$value string

juggleAttributes() публичный Метод

Juggles all attributes that are configured to be juggled.
public juggleAttributes ( )

juggleBoolean() публичный Метод

Returns the value as a boolean.
public juggleBoolean ( mixed $value ) : boolean
$value mixed
Результат boolean

juggleDate() публичный Метод

Returns the value as a Carbon instance.
См. также: Illuminate\Database\Eloquent\Model::asDateTime()
public juggleDate ( mixed $value ) : Carbon\Carbon\Carbon
$value mixed
Результат Carbon\Carbon\Carbon

juggleDateTime() публичный Метод

Returns a string formated as ISO standard of 0000-00-00 00:00:00.
public juggleDateTime ( mixed $value ) : string
$value mixed
Результат string

juggleFloat() публичный Метод

Returns the value as a float.
public juggleFloat ( mixed $value ) : float
$value mixed
Результат float

juggleInteger() публичный Метод

Returns the value as an integer.
public juggleInteger ( mixed $value ) : integer
$value mixed
Результат integer

juggleNull() публичный Метод

Casts to null on empty.
public juggleNull ( mixed $value ) : mixed | null
$value mixed
Результат mixed | null

juggleString() публичный Метод

Returns the value as a string.
public juggleString ( mixed $value ) : string
$value mixed
Результат string

juggleTimestamp() публичный Метод

Returns the date as a Unix timestamp.
public juggleTimestamp ( mixed $value ) : integer
$value mixed
Результат integer

juggleType() защищенный Метод

Casts the value to the type. Possibles types are: boolean, integer, float, string, array, object, null.
protected juggleType ( mixed $value, string $type ) : mixed
$value mixed
$type string
Результат mixed

mergeJugglable() публичный Метод

Merge an array of attributes with the jugglable array.
public mergeJugglable ( array $attributes )
$attributes array to juggle

removeJugglable() публичный Метод

Remove an attribute or several attributes from the jugglable array.
public removeJugglable ( mixed $attributes )
$attributes mixed

setDynamicJuggle() защищенный Метод

If juggling is active, it sets the attribute in the model by type juggling the value first.
protected setDynamicJuggle ( string $key, mixed $value )
$key string
$value mixed

setJugglable() публичный Метод

Set the jugglable attributes.
public setJugglable ( array $attributes )
$attributes array to juggle

setJuggling() публичный Метод

Set whether or not the model will juggle attributes.
public setJuggling ( $value )

Описание свойств

$juggling защищенное свойство

Whether the model is type juggling attributes or not.
protected bool $juggling
Результат boolean