PHP Трейт Mongolid\Model\Attributes

It is supposed to be used in model classes in general
Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
$mutable boolean Check if model should mutate attributes checking the existence of a specific method on model class. Default is true.

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

Свойство Тип Описание
$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.

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

Метод Описание
__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.

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

Метод Описание
buildMutatorMethod ( mixed $key, mixed $prefix ) : string Create mutator method pattern.
hasMutatorMethod ( mixed $key, mixed $prefix ) : boolean Verify if model has a mutator method defined.

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

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

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

__isset() публичный метод

Determine if an attribute exists on the model.
public __isset ( mixed $key ) : boolean
$key mixed Attribute name.
Результат boolean

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

Dynamically set attributes on the model.
public __set ( mixed $key, mixed $value ) : void
$key mixed Attribute name.
$value mixed Value to be set.
Результат void

__unset() публичный метод

Unset an attribute on the model.
public __unset ( mixed $key ) : void
$key mixed Attribute name.
Результат void

buildMutatorMethod() защищенный метод

Create mutator method pattern.
protected buildMutatorMethod ( mixed $key, mixed $prefix ) : string
$key mixed Attribute name.
$prefix mixed Method prefix to be used.
Результат string

cleanAttribute() публичный метод

Set a given attribute on the model.
public cleanAttribute ( string $key ) : void
$key string Name of the attribute to be unset.
Результат void

fill() публичный метод

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.
Результат void

getAttribute() публичный метод

Get an attribute from the model.
public getAttribute ( string $key ) : mixed
$key string The attribute to be accessed.
Результат mixed

getAttributes() публичный метод

Get all attributes from the model.
public getAttributes ( ) : mixed
Результат mixed

hasMutatorMethod() защищенный метод

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.
Результат boolean

setAttribute() публичный метод

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.
Результат void

syncOriginalAttributes() публичный метод

Ideally should be called once right after retrieving data from the database.
public syncOriginalAttributes ( ) : void
Результат void

toArray() публичный метод

Returns the model instance as an Array.
public toArray ( ) : array
Результат array

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

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

The model's attributes.
protected array $attributes
Результат array

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

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
Результат array

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

The attributes that are not mass assignable. The opposite to the fillable array;.
protected array $guarded
Результат array

$mutable публичное свойство

Check if model should mutate attributes checking the existence of a specific method on model class. Default is true.
public bool $mutable
Результат boolean

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

The model attribute's original state.
protected array $original
Результат array