PHP Trait Mongolid\Model\Attributes

It is supposed to be used in model classes in general
Afficher le fichier Open project: leroy-merlin-br/mongolid

Méthodes publiques

Свойство 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

Свойство 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.

Méthodes publiques

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

Méthodes protégées

Méthode 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 méthode

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

__isset() public méthode

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

__set() public méthode

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

__unset() public méthode

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

buildMutatorMethod() protected méthode

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

cleanAttribute() public méthode

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

fill() public méthode

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.
Résultat void

getAttribute() public méthode

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

getAttributes() public méthode

Get all attributes from the model.
public getAttributes ( ) : mixed
Résultat mixed

hasMutatorMethod() protected méthode

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.
Résultat boolean

setAttribute() public méthode

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.
Résultat void

syncOriginalAttributes() public méthode

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

toArray() public méthode

Returns the model instance as an Array.
public toArray ( ) : array
Résultat array

Property Details

$attributes protected_oe property

The model's attributes.
protected array $attributes
Résultat 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
Résultat array

$guarded protected_oe property

The attributes that are not mass assignable. The opposite to the fillable array;.
protected array $guarded
Résultat 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
Résultat boolean

$original protected_oe property

The model attribute's original state.
protected array $original
Résultat array