PHP Trait Esensi\Model\Traits\JugglingModelTrait

See also: Esensi\Model\Contracts\JugglingModelInterface
Author: Diego Caprioli ([email protected])
Author: Daniel LaBarge ([email protected])
Afficher le fichier Open project: esensi/model

Protected Properties

Свойство Type Description
$juggling boolean Whether the model is type juggling attributes or not.

Méthodes publiques

Méthode Description
__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.

Méthodes protégées

Méthode Description
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.

Method Details

__get() public méthode

Dynamically retrieve attributes on the model.
public __get ( string $key ) : mixed
$key string
Résultat mixed

__set() public méthode

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

addJugglable() public méthode

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

attributesToArray() public méthode

Override attributesToArray() Eloquent Model method, to type juggle first, and then call the parent method.
See also: Illuminate\Database\Eloquent\Model::attributestoArray()
public attributesToArray ( ) : array
Résultat array

buildJuggleMethod() public méthode

Build the method name that the type normalizes to.
public buildJuggleMethod ( string $type ) : string
$type string to cast
Résultat string

checkJuggleType() public méthode

Checks whether the type is a type that can be juggled to.
public checkJuggleType ( string $type ) : boolean
$type string to cast
Résultat boolean

getDynamicJuggle() protected méthode

If not it just returns the value as it was passed.
protected getDynamicJuggle ( string $key, mixed $value ) : mixed
$key string
$value mixed
Résultat mixed

getJugglable() public méthode

Get the juggable attributes.
public getJugglable ( ) : array
Résultat array

getJuggleType() public méthode

Gets the type that the attribute will be casted to.
public getJuggleType ( string $attribute ) : string
$attribute string
Résultat string

getJuggling() public méthode

Returns whether or not the model will juggle attributes.
public getJuggling ( ) : boolean
Résultat boolean

isJugglable() public méthode

Returns whether the attribute is type jugglable.
public isJugglable ( string $attribute ) : boolean
$attribute string name
Résultat boolean

isJuggleType() public méthode

Returns whether the type is a type that can be juggled to.
public isJuggleType ( string $type ) : boolean
$type string to cast
Résultat boolean

juggle() public méthode

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
Résultat mixed

juggleArray() public méthode

Returns the value as an array.
public juggleArray ( mixed $value ) : array
$value mixed
Résultat array

juggleAttribute() public méthode

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() public méthode

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

juggleBoolean() public méthode

Returns the value as a boolean.
public juggleBoolean ( mixed $value ) : boolean
$value mixed
Résultat boolean

juggleDate() public méthode

Returns the value as a Carbon instance.
See also: Illuminate\Database\Eloquent\Model::asDateTime()
public juggleDate ( mixed $value ) : Carbon\Carbon\Carbon
$value mixed
Résultat Carbon\Carbon\Carbon

juggleDateTime() public méthode

Returns a string formated as ISO standard of 0000-00-00 00:00:00.
public juggleDateTime ( mixed $value ) : string
$value mixed
Résultat string

juggleFloat() public méthode

Returns the value as a float.
public juggleFloat ( mixed $value ) : float
$value mixed
Résultat float

juggleInteger() public méthode

Returns the value as an integer.
public juggleInteger ( mixed $value ) : integer
$value mixed
Résultat integer

juggleNull() public méthode

Casts to null on empty.
public juggleNull ( mixed $value ) : mixed | null
$value mixed
Résultat mixed | null

juggleString() public méthode

Returns the value as a string.
public juggleString ( mixed $value ) : string
$value mixed
Résultat string

juggleTimestamp() public méthode

Returns the date as a Unix timestamp.
public juggleTimestamp ( mixed $value ) : integer
$value mixed
Résultat integer

juggleType() protected méthode

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
Résultat mixed

mergeJugglable() public méthode

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

removeJugglable() public méthode

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

setDynamicJuggle() protected méthode

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() public méthode

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

setJuggling() public méthode

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

Property Details

$juggling protected_oe property

Whether the model is type juggling attributes or not.
protected bool $juggling
Résultat boolean