class Model extends Extendable implements ArrayAccess, Arrayable, Jsonable, JsonSerializable

Model class.

Traits

Adds event related features to any class.

Extendable Trait Allows for "Private traits"

Properties

protected array $extensionData from  ExtendableTrait
static protected array $extendableCallbacks from  ExtendableTrait
static protected array $extendableStaticMethods from  ExtendableTrait
static protected bool $extendableGuardProperties from  ExtendableTrait
static protected ClassLoader $extendableClassLoader from  ExtendableTrait
$implement from  Extendable
protected array $hidden

The attributes that should be hidden for serialization.

from  HidesAttributes
protected array $visible

The attributes that should be visible in serialization.

from  HidesAttributes
array $attributes

The model's attributes.

from  HasAttributes
protected array $original

The model attribute's original state.

from  HasAttributes
protected array $changes

The changed model attributes.

from  HasAttributes
static bool $snakeAttributes

Indicates whether attributes are snake cased on arrays.

from  HasAttributes
static protected array $mutatorCache

The cache of the mutated attributes for each class.

from  HasAttributes
protected array $fillable

The attributes that are mass assignable.

from  GuardsAttributes
protected array $dispatchesEvents

The event map for the model.

from  HasEvents
protected array $observables

User exposed observable events.

from  HasEvents
static protected CacheManager $cache

The cache manager instance.

from  ManagesCache
protected bool $loadedFromCache from  ManagesCache
protected array $emitterSingleEvents from  EventEmitter
protected array $emitterEvents from  EventEmitter
protected array $emitterEventSorted from  EventEmitter
static protected SourceResolverInterface $resolver

The source resolver instance.

static $dispatcher
static protected array $booted

The array of booted models.

static protected array $eventsBooted

The array of booted events.

protected $source
protected string $dirName
protected array $appends

The accessors to append to the model's array form.

protected array $purgeable
bool $exists

Indicates if the model exists.

protected array $allowedExtensions
protected string $defaultExtension
protected int $maxNesting

Methods

extendableConstruct()

Constructor.

static void
extendableExtendCallback(callable $callback)

Helper method for ::extend() static method

static void
clearExtendedClasses()

Clear the list of extended classes so they will be re-extended.

string
extensionNormalizeClassName(string $name)

Normalizes the provided extension name allowing for the ClassLoader to inject aliased classes

extendClassWith(string $extensionName)

Dynamically extend a class with a specified behavior

void
extensionExtractMethods(string $extensionName, object $extensionObject)

Extracts the available methods from a behavior and adds it to the list of callable methods.

addDynamicMethod(string $dynamicName, callable $method, string $extension = null)

Programmatically adds a method to the extendable class

addDynamicProperty(string $dynamicName, string $value = null)

Programatically adds a property to the extendable class

bool
isClassExtendedWith(string $name)

Check if extendable class is extended with a behavior object

mixed
getClassExtension(string $name)

Returns a behavior object from an extendable class, example:

mixed
asExtension(string $shortName)

Short hand for getClassExtension() method, except takes the short extension name, example:

bool
methodExists(string $name)

Checks if a method exists, extension equivalent of method_exists()

array
getClassMethods()

Get a list of class methods, extension equivalent of get_class_methods()

array
getDynamicProperties()

Returns all dynamic properties and their values

bool
propertyExists(string $name)

Checks if a property exists, extension equivalent of property_exists()

bool
extendableIsAccessible(mixed $class, string $propertyName)

Checks if a property is accessible, property equivalent of is_callabe()

string
extendableGet(string $name)

Magic method for __get()

string
extendableSet(string $name, string $value)

Magic method for __set()

mixed
extendableCall(string $name, array $params = null)

Magic method for __call()

static mixed
extendableCallStatic(string $name, array $params = null)

Magic method for __callStatic()

ClassLoader|null
extensionGetClassLoader()

Gets the class loader

__construct(array $attributes = [])

Create a new Halcyon model instance.

__get(string $key)

Dynamically retrieve attributes on the model.

__set(string $key, $value)

Dynamically set attributes on the model.

__call(string $method, array $parameters)

Handle dynamic method calls into the model.

static 
__callStatic(string $method, array $parameters)

Handle dynamic static method calls into the method.

static 
extend(callable $callback)

No description

array
getHidden()

Get the hidden attributes for the model.

$this
setHidden(array $hidden)

Set the hidden attributes for the model.

void
addHidden(array|string|null $attributes = null)

Add hidden attributes for the model.

array
getVisible()

Get the visible attributes for the model.

$this
setVisible(array $visible)

Set the visible attributes for the model.

void
addVisible(array|string|null $attributes = null)

Add visible attributes for the model.

$this
makeVisible(array|string $attributes)

Make the given, typically hidden, attributes visible.

$this
makeHidden(array|string $attributes)

Make the given, typically visible, attributes hidden.

array
attributesToArray()

Convert the model's attributes to an array.

array
addMutatedAttributesToArray(array $attributes, array $mutatedAttributes)

Add the mutated attributes to the attributes array.

array
getArrayableAttributes()

Get an attribute array of all arrayable attributes.

array
getArrayableAppends()

Get all of the appendable values that are arrayable.

array
getArrayableItems(array $values)

Get an attribute array of all arrayable values.

mixed
getAttribute(string $key)

Get an attribute from the model.

mixed
getAttributeValue(string $key)

Get a plain attribute (not a relationship).

mixed
getAttributeFromArray(string $key)

Get an attribute from the $attributes array.

bool
hasGetMutator(string $key)

Determine if a get mutator exists for an attribute.

mixed
mutateAttribute(string $key, mixed $value)

Get the value of an attribute using its mutator.

mixed
mutateAttributeForArray(string $key, mixed $value)

Get the value of an attribute using its mutator for array conversion.

$this
setAttribute(string $key, mixed $value)

Set a given attribute on the model.

bool
hasSetMutator(string $key)

Determine if a set mutator exists for an attribute.

array
getAttributes()

Get all of the current attributes on the model.

$this
setRawAttributes(array $attributes, bool $sync = false)

Set the array of model attributes. No checking is done.

mixed|array
getOriginal(string|null $key = null, mixed $default = null)

Get the model's original attribute values.

array
only(array|mixed $attributes)

Get a subset of the model's attributes.

$this
syncOriginal()

Sync the original attributes with the current.

$this
syncOriginalAttribute(string $attribute)

Sync a single original attribute with its current value.

$this
syncChanges()

Sync the changed attributes.

bool
isDirty(array|string|null $attributes = null)

Determine if the model or given attribute(s) have been modified.

bool
isClean(array|string|null $attributes = null)

Determine if the model or given attribute(s) have remained the same.

bool
wasChanged(array|string|null $attributes = null)

Determine if the model or given attribute(s) have been modified.

bool
hasChanges(array $changes, array|string|null $attributes = null)

Determine if the given attributes were changed.

array
getDirty()

Get the attributes that have been changed since last sync.

array
getChanges()

Get the attributes that was changed.

bool
originalIsEquivalent(string $key, mixed $current)

Determine if the new and old values for a given key are equivalent.

array
getMutatedAttributes()

Get the mutated attributes for a given instance.

static void
cacheMutatedAttributes(string $class)

Extract and cache all the mutated attributes of a class.

static array
getMutatorMethods(mixed $class)

Get all of the attribute mutator methods.

array
getFillable()

Get the fillable attributes for the model.

$this
fillable(array $fillable)

Set the fillable attributes for the model.

array
fillableFromArray(array $attributes)

Get the fillable attributes of a given array.

bool
isFillable(string $key)

Determine if the given attribute may be mass assigned.

static void
observe(object|string $class)

Register an observer with the Model.

array
getObservableEvents()

Get the observable event names.

$this
setObservableEvents(array $observables)

Set the observable event names.

void
addObservableEvents(array|mixed $observables)

Add an observable event name.

void
removeObservableEvents(array|mixed $observables)

Remove an observable event name.

static void
registerModelEvent(string $event, Closure|string $callback, int $priority = 0)

Register a model event with the dispatcher.

bootNicerEvents()

Bind some nicer events to this model, in the format of method overrides.

mixed
fireModelEvent(string $event, bool $halt = true)

Fire the given event for the model.

mixed|null
fireCustomModelEvent(string $event, string $method)

Fire a custom model event for the given event.

mixed
filterModelEventResults(mixed $result)

Filter the model event results.

static void
retrieving(Closure|string $callback)

Create a new native event for handling beforeFetch().

static void
retrieved(Closure|string $callback)

Register a retrieved model event with the dispatcher.

static void
saving(Closure|string $callback, int $priority = 0)

Register a saving model event with the dispatcher.

static void
saved(Closure|string $callback, int $priority = 0)

Register a saved model event with the dispatcher.

static void
updating(Closure|string $callback, int $priority = 0)

Register an updating model event with the dispatcher.

static void
updated(Closure|string $callback, int $priority = 0)

Register an updated model event with the dispatcher.

static void
creating(Closure|string $callback, int $priority = 0)

Register a creating model event with the dispatcher.

static void
created(Closure|string $callback, int $priority = 0)

Register a created model event with the dispatcher.

static void
deleting(Closure|string $callback, int $priority = 0)

Register a deleting model event with the dispatcher.

static void
deleted(Closure|string $callback, int $priority = 0)

Register a deleted model event with the dispatcher.

static void
flushEventListeners()

Remove all of the event listeners for the model.

static Dispatcher
getEventDispatcher()

Get the event dispatcher instance.

static void
setEventDispatcher(Dispatcher $dispatcher)

Set the event dispatcher instance.

static void
unsetEventDispatcher()

Unset the event dispatcher for models.

static CacheManager
getCacheManager()

Get the cache manager instance.

static void
setCacheManager(CacheManager $cache)

Set the cache manager instance.

static void
unsetCacheManager()

Unset the cache manager for models.

static 
initCacheItem($item)

Initializes the object properties from the cached data. The extra data set here becomes available as attributes set on the model after fetch.

bool
isLoadedFromCache()

Returns true if the object was loaded from the cache.

void
setLoadedFromCache($value)

Returns true if the object was loaded from the cache.

bindEvent(string $event, callable $callback, int $priority = 0)

Create a new event binding.

bindEventOnce(string $event, callable $callback)

Create a new event binding that fires once only

void
emitterEventSortEvents(string $eventName)

Sort the listeners for a given event by priority.

unbindEvent(string $event = null)

Destroys an event binding.

string|array
fireEvent(string $event, array $params = [], bool $halt = false)

Fire an event and call the listeners.

mixed
fireSystemEvent(string $event, array $params = [], bool $halt = true)

Fires a combination of local and global events. The first segment is removed from the event name locally and the local object is passed as the first argument to the event globally. Halting is also enabled by default.

void
bootIfNotBooted()

Check if the model needs to be booted and if so, do it.

static void
boot()

The "booting" method of the model.

static void
bootTraits()

Boot all of the bootable traits on the model.

static void
clearBootedModels()

Clear the list of booted models so they will be re-booted.

static Model|Finder
on($source)

No description

static SourceInterface
resolveSource(string|null $source = null)

No description

getSourceResolver()

Get the source resolver instance.

static void
setSourceResolver(SourceResolverInterface $resolver)

Set the source resolver instance.

static void
unsetSourceResolver()

Unset the source resolver for models.

static Collection
hydrate(array $items, string|null $source = null)

Create a collection of models from plain arrays.

static Model
create(array $attributes = [])

Save a new model and return the instance.

static Finder
query()

Begin querying the model.

static Collection|Model[]
all()

Get all of the models from the source.

$this
fill(array $attributes)

Fill the model with an array of attributes.

getSource()

No description

setSource($source)

No description

string
getSourceName()

Get the current source name for the model.

string
getBaseFileNameAttribute()

Returns the file name without the extension.

array
getSettingsAttribute()

The settings is attribute contains everything that should be saved to the settings area.

setSettingsAttribute(mixed $value)

Filling the settings should merge it with attributes.

setFileNameAttribute(mixed $value)

File name should always contain an extension.

string
getTypeDirName()

Returns the directory name corresponding to the object type.

array
getAllowedExtensions()

Returns the allowable file extensions supported by this model.

int
getMaxNesting()

Returns the maximum directory nesting allowed by this template.

array
getFileNameParts(string $fileName = null)

Returns the base file name and extension. Applies a default extension, if none found.

newFinder()

Get a new file finder for the object

Collection
newCollection(array $models = [])

Create a new Collection instance.

newInstance(array $attributes = [], bool $exists = false)

Create a new instance of the given model.

newFromFinder(array $attributes = [], string|null $source = null)

Create a new model instance that is existing.

bool|int
update(array $attributes = [])

Update the model in the database.

bool
save(array $options = [])

Save the model to the source.

bool
saveInternal(array $options = [])

Save the model to the database. Is used by save()} and {@link forceSave().

void
finishSave(array $options)

Finish processing on a successful save operation.

bool
performUpdate(Finder $query, array $options = [])

Perform a model update operation.

bool
performInsert(Finder $query, array $options = [])

Perform a model insert operation.

bool|null
delete()

Delete the model from the database.

void
performDeleteOnModel()

Perform the actual delete query on this model instance.

string
__toString()

Convert the model to its string representation.

bool
__isset(string $key)

Determine if an attribute exists on the model.

void
__unset(string $key)

Unset an attribute on the model.

bool
offsetExists(mixed $offset)

Determine if the given attribute exists.

mixed
offsetGet(mixed $offset)

Get the value for a given offset.

void
offsetSet(mixed $offset, mixed $value)

Set the value for a given offset.

void
offsetUnset(mixed $offset)

Unset the value for a given offset.

array
toArray()

Get the instance as an array.

string
toJson(int $options = 0)

Convert the model instance to JSON.

array
jsonSerialize()

Convert the object into something JSON serializable.

Details

in ExtendableTrait at line 55
extendableConstruct()

Constructor.

in ExtendableTrait at line 103
static void extendableExtendCallback(callable $callback)

Helper method for ::extend() static method

Parameters

callable $callback

Return Value

void

in ExtendableTrait at line 120
static void clearExtendedClasses()

Clear the list of extended classes so they will be re-extended.

Return Value

void

in ExtendableTrait at line 131
protected string extensionNormalizeClassName(string $name)

Normalizes the provided extension name allowing for the ClassLoader to inject aliased classes

Parameters

string $name

Return Value

string

in ExtendableTrait at line 149
void|ExtendableTrait extendClassWith(string $extensionName)

Dynamically extend a class with a specified behavior

Parameters

string $extensionName

Return Value

void|ExtendableTrait

Exceptions

Exception

in ExtendableTrait at line 178
protected void extensionExtractMethods(string $extensionName, object $extensionObject)

Extracts the available methods from a behavior and adds it to the list of callable methods.

Parameters

string $extensionName
object $extensionObject

Return Value

void

in ExtendableTrait at line 206
addDynamicMethod(string $dynamicName, callable $method, string $extension = null)

Programmatically adds a method to the extendable class

Parameters

string $dynamicName
callable $method
string $extension

in ExtendableTrait at line 225
addDynamicProperty(string $dynamicName, string $value = null)

Programatically adds a property to the extendable class

Parameters

string $dynamicName
string $value

in ExtendableTrait at line 249
bool isClassExtendedWith(string $name)

Check if extendable class is extended with a behavior object

Parameters

string $name

Fully qualified behavior name

Return Value

bool

in ExtendableTrait at line 265
mixed getClassExtension(string $name)

Returns a behavior object from an extendable class, example:

$this->getClassExtension('Admin.Actions.FormController')

Parameters

string $name

Fully qualified behavior name

Return Value

mixed

in ExtendableTrait at line 280
mixed asExtension(string $shortName)

Short hand for getClassExtension() method, except takes the short extension name, example:

$this->asExtension('FormController')

Parameters

string $shortName

Return Value

mixed

in ExtendableTrait at line 301
bool methodExists(string $name)

Checks if a method exists, extension equivalent of method_exists()

Parameters

string $name

Return Value

bool

in ExtendableTrait at line 313
array getClassMethods()

Get a list of class methods, extension equivalent of get_class_methods()

Return Value

array

in ExtendableTrait at line 326
array getDynamicProperties()

Returns all dynamic properties and their values

Return Value

array

['property' => 'value']

in ExtendableTrait at line 344
bool propertyExists(string $name)

Checks if a property exists, extension equivalent of property_exists()

Parameters

string $name

Return Value

bool

in ExtendableTrait at line 370
protected bool extendableIsAccessible(mixed $class, string $propertyName)

Checks if a property is accessible, property equivalent of is_callabe()

Parameters

mixed $class
string $propertyName

Return Value

bool

in ExtendableTrait at line 385
string extendableGet(string $name)

Magic method for __get()

Parameters

string $name

Return Value

string

in ExtendableTrait at line 410
string extendableSet(string $name, string $value)

Magic method for __set()

Parameters

string $name
string $value

Return Value

string

in ExtendableTrait at line 444
mixed extendableCall(string $name, array $params = null)

Magic method for __call()

Parameters

string $name
array $params

Return Value

mixed

in ExtendableTrait at line 483
static mixed extendableCallStatic(string $name, array $params = null)

Magic method for __callStatic()

Parameters

string $name
array $params

Return Value

mixed

in ExtendableTrait at line 552
protected ClassLoader|null extensionGetClassLoader()

Gets the class loader

Return Value

ClassLoader|null

at line 98
__construct(array $attributes = [])

Create a new Halcyon model instance.

Parameters

array $attributes

at line 712
__get(string $key)

Dynamically retrieve attributes on the model.

Parameters

string $key

at line 725
__set(string $key, $value)

Dynamically set attributes on the model.

Parameters

string $key
$value

at line 738
__call(string $method, array $parameters)

Handle dynamic method calls into the model.

Parameters

string $method
array $parameters

at line 758
static __callStatic(string $method, array $parameters)

Handle dynamic static method calls into the method.

Parameters

string $method
array $parameters

in Extendable at line 50
static extend(callable $callback)

No description

Parameters

callable $callback

in HidesAttributes at line 26
array getHidden()

Get the hidden attributes for the model.

Return Value

array

in HidesAttributes at line 38
$this setHidden(array $hidden)

Set the hidden attributes for the model.

Parameters

array $hidden

Return Value

$this

in HidesAttributes at line 52
void addHidden(array|string|null $attributes = null)

Add hidden attributes for the model.

Parameters

array|string|null $attributes

Return Value

void

in HidesAttributes at line 64
array getVisible()

Get the visible attributes for the model.

Return Value

array

in HidesAttributes at line 76
$this setVisible(array $visible)

Set the visible attributes for the model.

Parameters

array $visible

Return Value

$this

in HidesAttributes at line 90
void addVisible(array|string|null $attributes = null)

Add visible attributes for the model.

Parameters

array|string|null $attributes

Return Value

void

in HidesAttributes at line 104
$this makeVisible(array|string $attributes)

Make the given, typically hidden, attributes visible.

Parameters

array|string $attributes

Return Value

$this

in HidesAttributes at line 122
$this makeHidden(array|string $attributes)

Make the given, typically visible, attributes hidden.

Parameters

array|string $attributes

Return Value

$this

in HasAttributes at line 51
array attributesToArray()

Convert the model's attributes to an array.

Return Value

array

in HasAttributes at line 77
protected array addMutatedAttributesToArray(array $attributes, array $mutatedAttributes)

Add the mutated attributes to the attributes array.

Parameters

array $attributes
array $mutatedAttributes

Return Value

array

in HasAttributes at line 103
protected array getArrayableAttributes()

Get an attribute array of all arrayable attributes.

Return Value

array

in HasAttributes at line 113
protected array getArrayableAppends()

Get all of the appendable values that are arrayable.

Return Value

array

in HasAttributes at line 131
protected array getArrayableItems(array $values)

Get an attribute array of all arrayable values.

Parameters

array $values

Return Value

array

in HasAttributes at line 151
mixed getAttribute(string $key)

Get an attribute from the model.

Parameters

string $key

Return Value

mixed

in HasAttributes at line 187
mixed getAttributeValue(string $key)

Get a plain attribute (not a relationship).

Parameters

string $key

Return Value

mixed

in HasAttributes at line 208
protected mixed getAttributeFromArray(string $key)

Get an attribute from the $attributes array.

Parameters

string $key

Return Value

mixed

in HasAttributes at line 222
bool hasGetMutator(string $key)

Determine if a get mutator exists for an attribute.

Parameters

string $key

Return Value

bool

in HasAttributes at line 235
protected mixed mutateAttribute(string $key, mixed $value)

Get the value of an attribute using its mutator.

Parameters

string $key
mixed $value

Return Value

mixed

in HasAttributes at line 248
protected mixed mutateAttributeForArray(string $key, mixed $value)

Get the value of an attribute using its mutator for array conversion.

Parameters

string $key
mixed $value

Return Value

mixed

in HasAttributes at line 263
$this setAttribute(string $key, mixed $value)

Set a given attribute on the model.

Parameters

string $key
mixed $value

Return Value

$this

in HasAttributes at line 286
bool hasSetMutator(string $key)

Determine if a set mutator exists for an attribute.

Parameters

string $key

Return Value

bool

in HasAttributes at line 296
array getAttributes()

Get all of the current attributes on the model.

Return Value

array

in HasAttributes at line 309
$this setRawAttributes(array $attributes, bool $sync = false)

Set the array of model attributes. No checking is done.

Parameters

array $attributes
bool $sync

Return Value

$this

in HasAttributes at line 328
mixed|array getOriginal(string|null $key = null, mixed $default = null)

Get the model's original attribute values.

Parameters

string|null $key
mixed $default

Return Value

mixed|array

in HasAttributes at line 340
array only(array|mixed $attributes)

Get a subset of the model's attributes.

Parameters

array|mixed $attributes

Return Value

array

in HasAttributes at line 356
$this syncOriginal()

Sync the original attributes with the current.

Return Value

$this

in HasAttributes at line 370
$this syncOriginalAttribute(string $attribute)

Sync a single original attribute with its current value.

Parameters

string $attribute

Return Value

$this

in HasAttributes at line 382
$this syncChanges()

Sync the changed attributes.

Return Value

$this

in HasAttributes at line 396
bool isDirty(array|string|null $attributes = null)

Determine if the model or given attribute(s) have been modified.

Parameters

array|string|null $attributes

Return Value

bool

in HasAttributes at line 410
bool isClean(array|string|null $attributes = null)

Determine if the model or given attribute(s) have remained the same.

Parameters

array|string|null $attributes

Return Value

bool

in HasAttributes at line 422
bool wasChanged(array|string|null $attributes = null)

Determine if the model or given attribute(s) have been modified.

Parameters

array|string|null $attributes

Return Value

bool

in HasAttributes at line 437
protected bool hasChanges(array $changes, array|string|null $attributes = null)

Determine if the given attributes were changed.

Parameters

array $changes
array|string|null $attributes

Return Value

bool

in HasAttributes at line 463
array getDirty()

Get the attributes that have been changed since last sync.

Return Value

array

in HasAttributes at line 481
array getChanges()

Get the attributes that was changed.

Return Value

array

in HasAttributes at line 494
protected bool originalIsEquivalent(string $key, mixed $current)

Determine if the new and old values for a given key are equivalent.

Parameters

string $key
mixed $current

Return Value

bool

in HasAttributes at line 518
array getMutatedAttributes()

Get the mutated attributes for a given instance.

Return Value

array

in HasAttributes at line 536
static void cacheMutatedAttributes(string $class)

Extract and cache all the mutated attributes of a class.

Parameters

string $class

Return Value

void

in HasAttributes at line 550
static protected array getMutatorMethods(mixed $class)

Get all of the attribute mutator methods.

Parameters

mixed $class

Return Value

array

in GuardsAttributes at line 21
array getFillable()

Get the fillable attributes for the model.

Return Value

array

in GuardsAttributes at line 33
$this fillable(array $fillable)

Set the fillable attributes for the model.

Parameters

array $fillable

Return Value

$this

in GuardsAttributes at line 47
protected array fillableFromArray(array $attributes)

Get the fillable attributes of a given array.

Parameters

array $attributes

Return Value

array

in GuardsAttributes at line 65
bool isFillable(string $key)

Determine if the given attribute may be mass assigned.

Parameters

string $key

Return Value

bool

in HasEvents at line 34
static void observe(object|string $class)

Register an observer with the Model.

Parameters

object|string $class

Return Value

void

in HasEvents at line 55
array getObservableEvents()

Get the observable event names.

Return Value

array

in HasEvents at line 74
$this setObservableEvents(array $observables)

Set the observable event names.

Parameters

array $observables

Return Value

$this

in HasEvents at line 88
void addObservableEvents(array|mixed $observables)

Add an observable event name.

Parameters

array|mixed $observables

Return Value

void

in HasEvents at line 102
void removeObservableEvents(array|mixed $observables)

Remove an observable event name.

Parameters

array|mixed $observables

Return Value

void

in HasEvents at line 118
static protected void registerModelEvent(string $event, Closure|string $callback, int $priority = 0)

Register a model event with the dispatcher.

Parameters

string $event
Closure|string $callback
int $priority

Return Value

void

in HasEvents at line 130
protected bootNicerEvents()

Bind some nicer events to this model, in the format of method overrides.

in HasEvents at line 177
protected mixed fireModelEvent(string $event, bool $halt = true)

Fire the given event for the model.

Parameters

string $event
bool $halt

Return Value

mixed

in HasEvents at line 209
protected mixed|null fireCustomModelEvent(string $event, string $method)

Fire a custom model event for the given event.

Parameters

string $event
string $method

Return Value

mixed|null

in HasEvents at line 229
protected mixed filterModelEventResults(mixed $result)

Filter the model event results.

Parameters

mixed $result

Return Value

mixed

in HasEvents at line 247
static void retrieving(Closure|string $callback)

Create a new native event for handling beforeFetch().

Parameters

Closure|string $callback

Return Value

void

in HasEvents at line 259
static void retrieved(Closure|string $callback)

Register a retrieved model event with the dispatcher.

Parameters

Closure|string $callback

Return Value

void

in HasEvents at line 272
static void saving(Closure|string $callback, int $priority = 0)

Register a saving model event with the dispatcher.

Parameters

Closure|string $callback
int $priority

Return Value

void

in HasEvents at line 285
static void saved(Closure|string $callback, int $priority = 0)

Register a saved model event with the dispatcher.

Parameters

Closure|string $callback
int $priority

Return Value

void

in HasEvents at line 298
static void updating(Closure|string $callback, int $priority = 0)

Register an updating model event with the dispatcher.

Parameters

Closure|string $callback
int $priority

Return Value

void

in HasEvents at line 311
static void updated(Closure|string $callback, int $priority = 0)

Register an updated model event with the dispatcher.

Parameters

Closure|string $callback
int $priority

Return Value

void

in HasEvents at line 324
static void creating(Closure|string $callback, int $priority = 0)

Register a creating model event with the dispatcher.

Parameters

Closure|string $callback
int $priority

Return Value

void

in HasEvents at line 337
static void created(Closure|string $callback, int $priority = 0)

Register a created model event with the dispatcher.

Parameters

Closure|string $callback
int $priority

Return Value

void

in HasEvents at line 350
static void deleting(Closure|string $callback, int $priority = 0)

Register a deleting model event with the dispatcher.

Parameters

Closure|string $callback
int $priority

Return Value

void

in HasEvents at line 363
static void deleted(Closure|string $callback, int $priority = 0)

Register a deleted model event with the dispatcher.

Parameters

Closure|string $callback
int $priority

Return Value

void

in HasEvents at line 373
static void flushEventListeners()

Remove all of the event listeners for the model.

Return Value

void

in HasEvents at line 391
static Dispatcher getEventDispatcher()

Get the event dispatcher instance.

Return Value

Dispatcher

in HasEvents at line 403
static void setEventDispatcher(Dispatcher $dispatcher)

Set the event dispatcher instance.

Parameters

Dispatcher $dispatcher

Return Value

void

in HasEvents at line 413
static void unsetEventDispatcher()

Unset the event dispatcher for models.

Return Value

void

in ManagesCache at line 22
static CacheManager getCacheManager()

Get the cache manager instance.

Return Value

CacheManager

in ManagesCache at line 34
static void setCacheManager(CacheManager $cache)

Set the cache manager instance.

Parameters

CacheManager $cache

Return Value

void

in ManagesCache at line 43
static void unsetCacheManager()

Unset the cache manager for models.

Return Value

void

in ManagesCache at line 54
static initCacheItem($item)

Initializes the object properties from the cached data. The extra data set here becomes available as attributes set on the model after fetch.

Parameters

$item

in ManagesCache at line 62
bool isLoadedFromCache()

Returns true if the object was loaded from the cache.

Return Value

bool

in ManagesCache at line 74
void setLoadedFromCache($value)

Returns true if the object was loaded from the cache.

Parameters

$value

Return Value

void

in EventEmitter at line 36
EventEmitter bindEvent(string $event, callable $callback, int $priority = 0)

Create a new event binding.

Parameters

string $event

The event name to listen for

callable $callback

The callback to call when emitted

int $priority

Return Value

EventEmitter

in EventEmitter at line 52
EventEmitter bindEventOnce(string $event, callable $callback)

Create a new event binding that fires once only

Parameters

string $event

The event name

callable $callback

Return Value

EventEmitter

in EventEmitter at line 66
protected void emitterEventSortEvents(string $eventName)

Sort the listeners for a given event by priority.

Parameters

string $eventName

Return Value

void

in EventEmitter at line 84
EventEmitter unbindEvent(string $event = null)

Destroys an event binding.

Parameters

string $event

Event to destroy

Return Value

EventEmitter

in EventEmitter at line 124
string|array fireEvent(string $event, array $params = [], bool $halt = false)

Fire an event and call the listeners.

Parameters

string $event

Event name

array $params

Event parameters

bool $halt

Halt after first non-null result

Return Value

string|array

Collection of event results / Or single result (if halted)

in EventEmitter at line 178
mixed fireSystemEvent(string $event, array $params = [], bool $halt = true)

Fires a combination of local and global events. The first segment is removed from the event name locally and the local object is passed as the first argument to the event globally. Halting is also enabled by default.

For example:

$this->fireSystemEvent('admin.form.myEvent', ['my value']);

Is equivalent to:

$this->fireEvent('form.myEvent', ['myvalue'], true);

Event::fire('admin.form.myEvent', [$this, 'myvalue'], true);

Parameters

string $event

Event name

array $params

Event parameters

bool $halt

Halt after first non-null result

Return Value

mixed

at line 116
protected void bootIfNotBooted()

Check if the model needs to be booted and if so, do it.

Return Value

void

at line 134
static protected void boot()

The "booting" method of the model.

Return Value

void

at line 144
static protected void bootTraits()

Boot all of the bootable traits on the model.

Return Value

void

at line 160
static void clearBootedModels()

Clear the list of booted models so they will be re-booted.

Return Value

void

at line 170
static Model|Finder on($source)

No description

Parameters

$source

Return Value

Model|Finder

at line 184
static SourceInterface resolveSource(string|null $source = null)

No description

Parameters

string|null $source

Return Value

SourceInterface

at line 193
static SourceResolverInterface getSourceResolver()

Get the source resolver instance.

at line 205
static void setSourceResolver(SourceResolverInterface $resolver)

Set the source resolver instance.

Parameters

SourceResolverInterface $resolver

Return Value

void

at line 214
static void unsetSourceResolver()

Unset the source resolver for models.

Return Value

void

at line 227
static Collection hydrate(array $items, string|null $source = null)

Create a collection of models from plain arrays.

Parameters

array $items
string|null $source

Return Value

Collection

at line 246
static Model create(array $attributes = [])

Save a new model and return the instance.

Parameters

array $attributes

Return Value

Model

at line 260
static Finder query()

Begin querying the model.

Return Value

Finder

at line 270
static Collection|Model[] all()

Get all of the models from the source.

Return Value

Collection|Model[]

at line 286
$this fill(array $attributes)

Fill the model with an array of attributes.

Parameters

array $attributes

Return Value

$this

Exceptions

MassAssignmentException

at line 300
SourceInterface getSource()

No description

Return Value

SourceInterface

at line 310
Model setSource($source)

No description

Parameters

$source

Return Value

Model

at line 321
string getSourceName()

Get the current source name for the model.

Return Value

string

at line 330
string getBaseFileNameAttribute()

Returns the file name without the extension.

Return Value

string

at line 345
array getSettingsAttribute()

The settings is attribute contains everything that should be saved to the settings area.

Return Value

array

at line 364
setSettingsAttribute(mixed $value)

Filling the settings should merge it with attributes.

Parameters

mixed $value

at line 375
setFileNameAttribute(mixed $value)

File name should always contain an extension.

Parameters

mixed $value

at line 391
string getTypeDirName()

Returns the directory name corresponding to the object type.

For pages the directory name is "_pages", for layouts - "_layouts", etc.

Return Value

string

at line 400
array getAllowedExtensions()

Returns the allowable file extensions supported by this model.

Return Value

array

at line 409
int getMaxNesting()

Returns the maximum directory nesting allowed by this template.

Return Value

int

at line 421
array getFileNameParts(string $fileName = null)

Returns the base file name and extension. Applies a default extension, if none found.

Parameters

string $fileName

Return Value

array

at line 450
Finder newFinder()

Get a new file finder for the object

Return Value

Finder

at line 466
Collection newCollection(array $models = [])

Create a new Collection instance.

Parameters

array $models

Return Value

Collection

at line 479
Model newInstance(array $attributes = [], bool $exists = false)

Create a new instance of the given model.

Parameters

array $attributes
bool $exists

Return Value

Model

at line 499
Model newFromFinder(array $attributes = [], string|null $source = null)

Create a new model instance that is existing.

Parameters

array $attributes
string|null $source

Return Value

Model

at line 519
bool|int update(array $attributes = [])

Update the model in the database.

Parameters

array $attributes

Return Value

bool|int

at line 535
bool save(array $options = [])

Save the model to the source.

Parameters

array $options

Return Value

bool

at line 547
bool saveInternal(array $options = [])

Save the model to the database. Is used by save()} and {@link forceSave().

Parameters

array $options

Return Value

bool

at line 584
protected void finishSave(array $options)

Finish processing on a successful save operation.

Parameters

array $options

Return Value

void

at line 601
protected bool performUpdate(Finder $query, array $options = [])

Perform a model update operation.

Parameters

Finder $query
array $options

Return Value

bool

at line 633
protected bool performInsert(Finder $query, array $options = [])

Perform a model insert operation.

Parameters

Finder $query
array $options

Return Value

bool

at line 662
bool|null delete()

Delete the model from the database.

Return Value

bool|null

Exceptions

Exception

at line 691
protected void performDeleteOnModel()

Perform the actual delete query on this model instance.

Return Value

void

at line 700
string __toString()

Convert the model to its string representation.

Return Value

string

at line 772
bool __isset(string $key)

Determine if an attribute exists on the model.

Parameters

string $key

Return Value

bool

at line 788
void __unset(string $key)

Unset an attribute on the model.

Parameters

string $key

Return Value

void

at line 800
bool offsetExists(mixed $offset)

Determine if the given attribute exists.

Parameters

mixed $offset

Return Value

bool

at line 812
mixed offsetGet(mixed $offset)

Get the value for a given offset.

Parameters

mixed $offset

Return Value

mixed

at line 825
void offsetSet(mixed $offset, mixed $value)

Set the value for a given offset.

Parameters

mixed $offset
mixed $value

Return Value

void

at line 837
void offsetUnset(mixed $offset)

Unset the value for a given offset.

Parameters

mixed $offset

Return Value

void

at line 846
array toArray()

Get the instance as an array.

Return Value

array

at line 858
string toJson(int $options = 0)

Convert the model instance to JSON.

Parameters

int $options

Return Value

string

at line 868
array jsonSerialize()

Convert the object into something JSON serializable.

Return Value

array