PHP Trait Mongolid\Model\Attributes

It is supposed to be used in model classes in general
Datei anzeigen Open project: leroy-merlin-br/mongolid

Public Properties

Property Type Description
$mutable boolean Check if model should mutate attributes checking the existence of a specific method on model class. Default is true.

Protected Properties

Property Type Description
$attributes array The model's attributes.
$fillable array Once you put at least one string in this array, only the attributes specified here will be changed with the setAttributes method.
$guarded array The attributes that are not mass assignable. The opposite to the fillable array;.
$original array The model attribute's original state.

Public Methods

Method Description
__get ( mixed $key ) : mixed Dynamically retrieve attributes on the model.
__isset ( mixed $key ) : boolean Determine if an attribute exists on the model.
__set ( mixed $key, mixed $value ) : void Dynamically set attributes on the model.
__unset ( mixed $key ) : void Unset an attribute on the model.
cleanAttribute ( string $key ) : void Set a given attribute on the model.
fill ( array $input, boolean $force = false ) : void Set the model attributes using an array.
getAttribute ( string $key ) : mixed Get an attribute from the model.
getAttributes ( ) : mixed Get all attributes from the model.
setAttribute ( string $key, mixed $value ) : void Set a given attribute on the model.
syncOriginalAttributes ( ) : void Stores original attributes from actual data from attributes to be used in future comparisons about changes.
toArray ( ) : array Returns the model instance as an Array.

Protected Methods

Method Description
buildMutatorMethod ( mixed $key, mixed $prefix ) : string Create mutator method pattern.
hasMutatorMethod ( mixed $key, mixed $prefix ) : boolean Verify if model has a mutator method defined.

Method Details

__get() public method

Dynamically retrieve attributes on the model.
public __get ( mixed $key ) : mixed
$key mixed Name of the attribute.
return mixed

__isset() public method

Determine if an attribute exists on the model.
public __isset ( mixed $key ) : boolean
$key mixed Attribute name.
return boolean

__set() public method

Dynamically set attributes on the model.
public __set ( mixed $key, mixed $value ) : void
$key mixed Attribute name.
$value mixed Value to be set.
return void

__unset() public method

Unset an attribute on the model.
public __unset ( mixed $key ) : void
$key mixed Attribute name.
return void

buildMutatorMethod() protected method

Create mutator method pattern.
protected buildMutatorMethod ( mixed $key, mixed $prefix ) : string
$key mixed Attribute name.
$prefix mixed Method prefix to be used.
return string

cleanAttribute() public method

Set a given attribute on the model.
public cleanAttribute ( string $key ) : void
$key string Name of the attribute to be unset.
return void

fill() public method

Set the model attributes using an array.
public fill ( array $input, boolean $force = false ) : void
$input array The data that will be used to fill the attributes.
$force boolean Force fill.
return void

getAttribute() public method

Get an attribute from the model.
public getAttribute ( string $key ) : mixed
$key string The attribute to be accessed.
return mixed

getAttributes() public method

Get all attributes from the model.
public getAttributes ( ) : mixed
return mixed

hasMutatorMethod() protected method

Verify if model has a mutator method defined.
protected hasMutatorMethod ( mixed $key, mixed $prefix ) : boolean
$key mixed Attribute name.
$prefix mixed Method prefix to be used.
return boolean

setAttribute() public method

Set a given attribute on the model.
public setAttribute ( string $key, mixed $value ) : void
$key string Name of the attribute to be set.
$value mixed Value to be set.
return void

syncOriginalAttributes() public method

Ideally should be called once right after retrieving data from the database.
public syncOriginalAttributes ( ) : void
return void

toArray() public method

Returns the model instance as an Array.
public toArray ( ) : array
return array

Property Details

$attributes protected_oe property

The model's attributes.
protected array $attributes
return array

$fillable protected_oe property

Once you put at least one string in this array, only the attributes specified here will be changed with the setAttributes method.
protected array $fillable
return array

$guarded protected_oe property

The attributes that are not mass assignable. The opposite to the fillable array;.
protected array $guarded
return array

$mutable public_oe property

Check if model should mutate attributes checking the existence of a specific method on model class. Default is true.
public bool $mutable
return boolean

$original protected_oe property

The model attribute's original state.
protected array $original
return array