PHP Class Jenssegers\Model\Model

Inheritance: implements ArrayAcces\ArrayAccess, implements Illuminate\Contracts\Support\Arrayable, implements Illuminate\Contracts\Support\Jsonable, implements JsonSerializabl\JsonSerializable
Afficher le fichier Open project: jenssegers/model Class Usage Examples

Méthodes publiques

Свойство Type Description
$snakeAttributes boolean Indicates whether attributes are snake cased on arrays.

Protected Properties

Свойство Type Description
$appends array The accessors to append to the model's array form.
$attributes array The model's attributes.
$casts array The attributes that should be casted to native types.
$fillable array The attributes that are mass assignable.
$guarded array The attributes that aren't mass assignable.
$hidden array The attributes that should be hidden for arrays.
$mutatorCache array The cache of the mutated attributes for each class.
$unguarded boolean Indicates if all mass assignment is enabled.
$visible array The attributes that should be visible in arrays.

Méthodes publiques

Méthode Description
__callStatic ( string $method, array $parameters ) : mixed Handle dynamic static method calls into the method.
__construct ( array $attributes = [] ) : void Create a new Eloquent model instance.
__get ( string $key ) : mixed Dynamically retrieve attributes on the model.
__isset ( string $key ) : boolean Determine if an attribute exists on the model.
__set ( string $key, mixed $value ) : void Dynamically set attributes on the model.
__toString ( ) : string Convert the model to its string representation.
__unset ( string $key ) : void Unset an attribute on the model.
addHidden ( array | string | null $attributes = null ) : void Add hidden attributes for the model.
addVisible ( array | string | null $attributes = null ) : void Add visible attributes for the model.
attributesToArray ( ) : array Convert the model's attributes to an array.
cacheMutatedAttributes ( string $class ) : void Extract and cache all the mutated attributes of a class.
fill ( array $attributes ) Fill the model with an array of attributes.
fillable ( array $fillable ) Set the fillable attributes for the model.
forceFill ( array $attributes ) Fill the model with an array of attributes. Force mass assignment.
fromJson ( string $value, boolean $asObject = false ) : mixed Decode the given JSON back into an array or object.
getAttribute ( string $key ) : mixed Get an attribute from the model.
getAttributes ( ) : array Get all of the current attributes on the model.
getFillable ( ) : array Get the fillable attributes for the model.
getGuarded ( ) : array Get the guarded attributes for the model.
getHidden ( ) : array Get the hidden attributes for the model.
getMutatedAttributes ( ) : array Get the mutated attributes for a given instance.
getVisible ( ) : array Get the visible attributes for the model.
guard ( array $guarded ) Set the guarded attributes for the model.
hasGetMutator ( string $key ) : boolean Determine if a get mutator exists for an attribute.
hasSetMutator ( string $key ) : boolean Determine if a set mutator exists for an attribute.
hydrate ( array $items ) : array Create a collection of models from plain arrays.
isFillable ( string $key ) : boolean Determine if the given attribute may be mass assigned.
isGuarded ( string $key ) : boolean Determine if the given key is guarded.
isUnguarded ( ) : boolean Determine if current state is "unguarded".
jsonSerialize ( ) : array Convert the object into something JSON serializable.
newInstance ( array $attributes = [] ) : Model Create a new instance of the given model.
offsetExists ( mixed $offset ) : boolean Determine if the given attribute exists.
offsetGet ( mixed $offset ) : mixed Get the value for a given offset.
offsetSet ( mixed $offset, mixed $value ) : void Set the value for a given offset.
offsetUnset ( mixed $offset ) : void Unset the value for a given offset.
reguard ( ) : void Enable the mass assignment restrictions.
replicate ( array $except = null ) : Model Clone the model into a new, non-existing instance.
setAppends ( array $appends ) Set the accessors to append to model arrays.
setAttribute ( string $key, mixed $value ) Set a given attribute on the model.
setHidden ( array $hidden ) Set the hidden attributes for the model.
setVisible ( array $visible ) Set the visible attributes for the model.
toArray ( ) : array Convert the model instance to an array.
toJson ( integer $options ) : string Convert the model instance to JSON.
totallyGuarded ( ) : boolean Determine if the model is totally guarded.
unguard ( boolean $state = true ) : void Disable all mass assignable restrictions.
unguarded ( callable $callback ) : mixed Run the given callable while being unguarded.
withHidden ( array | string $attributes ) Make the given, typically hidden, attributes visible.

Méthodes protégées

Méthode Description
asJson ( mixed $value ) : string Encode the given value as JSON.
castAttribute ( string $key, mixed $value ) : mixed Cast an attribute to a native PHP type.
fillableFromArray ( array $attributes ) : array Get the fillable attributes of a given array.
getArrayableAppends ( ) : array Get all of the appendable values that are arrayable.
getArrayableAttributes ( ) : array Get an attribute array of all arrayable attributes.
getArrayableItems ( array $values ) : array Get an attribute array of all arrayable values.
getAttributeFromArray ( string $key ) : mixed Get an attribute from the $attributes array.
getAttributeValue ( string $key ) : mixed Get a plain attribute (not a relationship).
getCastType ( string $key ) : string Get the type of cast for a model attribute.
hasCast ( string $key ) : boolean Determine whether an attribute should be casted to a native type.
isJsonCastable ( string $key ) : boolean Determine whether a value is JSON castable for inbound manipulation.
mutateAttribute ( string $key, mixed $value ) : mixed Get the value of an attribute using its mutator.
mutateAttributeForArray ( string $key, mixed $value ) : mixed Get the value of an attribute using its mutator for array conversion.

Method Details

__callStatic() public static méthode

Handle dynamic static method calls into the method.
public static __callStatic ( string $method, array $parameters ) : mixed
$method string
$parameters array
Résultat mixed

__construct() public méthode

Create a new Eloquent model instance.
public __construct ( array $attributes = [] ) : void
$attributes array
Résultat void

__get() public méthode

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

__isset() public méthode

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

__set() public méthode

Dynamically set attributes on the model.
public __set ( string $key, mixed $value ) : void
$key string
$value mixed
Résultat void

__toString() public méthode

Convert the model to its string representation.
public __toString ( ) : string
Résultat string

__unset() public méthode

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

addHidden() public méthode

Add hidden attributes for the model.
public addHidden ( array | string | null $attributes = null ) : void
$attributes array | string | null
Résultat void

addVisible() public méthode

Add visible attributes for the model.
public addVisible ( array | string | null $attributes = null ) : void
$attributes array | string | null
Résultat void

asJson() protected méthode

Encode the given value as JSON.
protected asJson ( mixed $value ) : string
$value mixed
Résultat string

attributesToArray() public méthode

Convert the model's attributes to an array.
public attributesToArray ( ) : array
Résultat array

cacheMutatedAttributes() public static méthode

Extract and cache all the mutated attributes of a class.
public static cacheMutatedAttributes ( string $class ) : void
$class string
Résultat void

castAttribute() protected méthode

Cast an attribute to a native PHP type.
protected castAttribute ( string $key, mixed $value ) : mixed
$key string
$value mixed
Résultat mixed

fill() public méthode

Fill the model with an array of attributes.
public fill ( array $attributes )
$attributes array

fillable() public méthode

Set the fillable attributes for the model.
public fillable ( array $fillable )
$fillable array

fillableFromArray() protected méthode

Get the fillable attributes of a given array.
protected fillableFromArray ( array $attributes ) : array
$attributes array
Résultat array

forceFill() public méthode

Fill the model with an array of attributes. Force mass assignment.
public forceFill ( array $attributes )
$attributes array

fromJson() public méthode

Decode the given JSON back into an array or object.
public fromJson ( string $value, boolean $asObject = false ) : mixed
$value string
$asObject boolean
Résultat mixed

getArrayableAppends() protected méthode

Get all of the appendable values that are arrayable.
protected getArrayableAppends ( ) : array
Résultat array

getArrayableAttributes() protected méthode

Get an attribute array of all arrayable attributes.
protected getArrayableAttributes ( ) : array
Résultat array

getArrayableItems() protected méthode

Get an attribute array of all arrayable values.
protected getArrayableItems ( array $values ) : array
$values array
Résultat array

getAttribute() public méthode

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

getAttributeFromArray() protected méthode

Get an attribute from the $attributes array.
protected getAttributeFromArray ( string $key ) : mixed
$key string
Résultat mixed

getAttributeValue() protected méthode

Get a plain attribute (not a relationship).
protected getAttributeValue ( string $key ) : mixed
$key string
Résultat mixed

getAttributes() public méthode

Get all of the current attributes on the model.
public getAttributes ( ) : array
Résultat array

getCastType() protected méthode

Get the type of cast for a model attribute.
protected getCastType ( string $key ) : string
$key string
Résultat string

getFillable() public méthode

Get the fillable attributes for the model.
public getFillable ( ) : array
Résultat array

getGuarded() public méthode

Get the guarded attributes for the model.
public getGuarded ( ) : array
Résultat array

getHidden() public méthode

Get the hidden attributes for the model.
public getHidden ( ) : array
Résultat array

getMutatedAttributes() public méthode

Get the mutated attributes for a given instance.
public getMutatedAttributes ( ) : array
Résultat array

getVisible() public méthode

Get the visible attributes for the model.
public getVisible ( ) : array
Résultat array

guard() public méthode

Set the guarded attributes for the model.
public guard ( array $guarded )
$guarded array

hasCast() protected méthode

Determine whether an attribute should be casted to a native type.
protected hasCast ( string $key ) : boolean
$key string
Résultat boolean

hasGetMutator() public méthode

Determine if a get mutator exists for an attribute.
public hasGetMutator ( string $key ) : boolean
$key string
Résultat boolean

hasSetMutator() public méthode

Determine if a set mutator exists for an attribute.
public hasSetMutator ( string $key ) : boolean
$key string
Résultat boolean

hydrate() public static méthode

Create a collection of models from plain arrays.
public static hydrate ( array $items ) : array
$items array
Résultat array

isFillable() public méthode

Determine if the given attribute may be mass assigned.
public isFillable ( string $key ) : boolean
$key string
Résultat boolean

isGuarded() public méthode

Determine if the given key is guarded.
public isGuarded ( string $key ) : boolean
$key string
Résultat boolean

isJsonCastable() protected méthode

Determine whether a value is JSON castable for inbound manipulation.
protected isJsonCastable ( string $key ) : boolean
$key string
Résultat boolean

isUnguarded() public static méthode

Determine if current state is "unguarded".
public static isUnguarded ( ) : boolean
Résultat boolean

jsonSerialize() public méthode

Convert the object into something JSON serializable.
public jsonSerialize ( ) : array
Résultat array

mutateAttribute() protected méthode

Get the value of an attribute using its mutator.
protected mutateAttribute ( string $key, mixed $value ) : mixed
$key string
$value mixed
Résultat mixed

mutateAttributeForArray() protected méthode

Get the value of an attribute using its mutator for array conversion.
protected mutateAttributeForArray ( string $key, mixed $value ) : mixed
$key string
$value mixed
Résultat mixed

newInstance() public méthode

Create a new instance of the given model.
public newInstance ( array $attributes = [] ) : Model
$attributes array
Résultat Model

offsetExists() public méthode

Determine if the given attribute exists.
public offsetExists ( mixed $offset ) : boolean
$offset mixed
Résultat boolean

offsetGet() public méthode

Get the value for a given offset.
public offsetGet ( mixed $offset ) : mixed
$offset mixed
Résultat mixed

offsetSet() public méthode

Set the value for a given offset.
public offsetSet ( mixed $offset, mixed $value ) : void
$offset mixed
$value mixed
Résultat void

offsetUnset() public méthode

Unset the value for a given offset.
public offsetUnset ( mixed $offset ) : void
$offset mixed
Résultat void

reguard() public static méthode

Enable the mass assignment restrictions.
public static reguard ( ) : void
Résultat void

replicate() public méthode

Clone the model into a new, non-existing instance.
public replicate ( array $except = null ) : Model
$except array
Résultat Model

setAppends() public méthode

Set the accessors to append to model arrays.
public setAppends ( array $appends )
$appends array

setAttribute() public méthode

Set a given attribute on the model.
public setAttribute ( string $key, mixed $value )
$key string
$value mixed

setHidden() public méthode

Set the hidden attributes for the model.
public setHidden ( array $hidden )
$hidden array

setVisible() public méthode

Set the visible attributes for the model.
public setVisible ( array $visible )
$visible array

toArray() public méthode

Convert the model instance to an array.
public toArray ( ) : array
Résultat array

toJson() public méthode

Convert the model instance to JSON.
public toJson ( integer $options ) : string
$options integer
Résultat string

totallyGuarded() public méthode

Determine if the model is totally guarded.
public totallyGuarded ( ) : boolean
Résultat boolean

unguard() public static méthode

Disable all mass assignable restrictions.
public static unguard ( boolean $state = true ) : void
$state boolean
Résultat void

unguarded() public static méthode

Run the given callable while being unguarded.
public static unguarded ( callable $callback ) : mixed
$callback callable
Résultat mixed

withHidden() public méthode

Make the given, typically hidden, attributes visible.
public withHidden ( array | string $attributes )
$attributes array | string

Property Details

$appends protected_oe property

The accessors to append to the model's array form.
protected array $appends
Résultat array

$attributes protected_oe property

The model's attributes.
protected array $attributes
Résultat array

$casts protected_oe property

The attributes that should be casted to native types.
protected array $casts
Résultat array

$fillable protected_oe property

The attributes that are mass assignable.
protected array $fillable
Résultat array

$guarded protected_oe property

The attributes that aren't mass assignable.
protected array $guarded
Résultat array

$hidden protected_oe property

The attributes that should be hidden for arrays.
protected array $hidden
Résultat array

$mutatorCache protected_oe static_oe property

The cache of the mutated attributes for each class.
protected static array $mutatorCache
Résultat array

$snakeAttributes public_oe static_oe property

Indicates whether attributes are snake cased on arrays.
public static bool $snakeAttributes
Résultat boolean

$unguarded protected_oe static_oe property

Indicates if all mass assignment is enabled.
protected static bool $unguarded
Résultat boolean

$visible protected_oe property

The attributes that should be visible in arrays.
protected array $visible
Résultat array