October\Rain\Halcyon\Model

Overview

Model is a base template object, equivalent to a Model in ORM

Extends
Implements
  • ArrayAccess
  • Illuminate\Contracts\Support\Arrayable
  • Illuminate\Contracts\Support\Jsonable
  • JsonSerializable
  • Stringable

Public Properties

public array $attributes

attributes saved to the settings area.

public bool $exists

exists indicates if the model exists.

Show inherited public properties

Inherited Public Properties

Protected Properties

protected string $datasource

datasource is the data source for the model, a directory path.

protected string $dirName

dirName is the container name associated with the model, eg: pages.

protected array $original

original attributes.

protected array $appends

appends to the model's array form.

protected array $fillable

fillable attributes are mass assignable

protected array $purgeable

List of attribute names which are not considered "settings".

protected array $allowedExtensions

allowedExtensions is allowable file extensions.

protected string $defaultExtension

defaultExtension is default file extension.

protected bool $isCompoundObject

isCompoundObject supports code and settings sections.

protected bool $wrapCode

wrapCode section in PHP tags.

protected int $maxNesting

maxNesting is the maximum allowed path nesting level. The default value is 5, meaning that files can only exist in the root directory, or in a subdirectory. Set to null if any level is allowed.

protected bool $loadedFromCache

loadedFromCache indicates whether the object was loaded from the cache.

protected static Illuminate\Cache\CacheManager $cache

cache manager

protected static October\Rain\Halcyon\Datasource\ResolverInterface $resolver

resolver instance.

protected static array $mutatorCache

mutatorCache for each class.

protected static array $booted

booted models

protected static array $traitInitializers

traitInitializers that will be called on each new instance.

protected array $emitterSingleEventCollection

emitterSingleEventCollection of events to be fired once only

protected array $emitterEventCollection

emitterEventCollection of all registered events

protected array $emitterEventSorted

emitterEventSorted collection

protected static array $eventsBooted

eventsBooted is the array of models booted events.

protected static Illuminate\Contracts\Events\Dispatcher $dispatcher

dispatcher instance

protected array $observables

observables are user exposed observable events.

Show inherited protected properties

Inherited Protected Properties


Public Methods

public __call()

public __call(string $method, array $parameters): mixed 

__call handles dynamic method calls into the model.

public static __callStatic()

public static __callStatic(string $method, array $parameters): mixed 

__callStatic handles dynamic static method calls into the method.

public __construct()

public __construct(array $attributes = []): void 

__construct a new Halcyon model instance.

public __get()

public __get(string $key): mixed 

__get dynamically retrieve attributes on the model.

public __isset()

public __isset(string $key): bool 

__isset determines if an attribute exists on the model.

public __set()

public __set(string $key, mixed $value): void 

__set dynamically set attributes on the model.

public __sleep()

public __sleep(): void

__sleep prepare the object for serialization.

public __toString()

public __toString(): string 

__toString converts the model to its string representation.

public __unset()

public __unset(string $key): void 

__unset an attribute on the model.

public __wakeup()

public __wakeup(): void

__wakeup when a model is being unserialized, check if it needs to be booted.

public addFillable()

public addFillable(array|string|null $attributes = null): void 

addFillable adds fillable attributes for the model.

public addObservableEvents()

public addObservableEvents(array|mixed $observables): void 

addObservableEvents name.

public addPurgeable()

public addPurgeable(array|string|null $attributes = null): void 

addPurgeable adds an attribute to the purgeable attributes list

public static all()

public static all(): October\Rain\Halcyon\Collection|static[] 

all of the models from the datasource.

public attributesToArray()

public attributesToArray(): array 

attributesToArray converts the model's attributes to an array.

public bindEvent()

public bindEvent($event, $callback, $priority = 0): void 

bindEvent creates a new event binding

public bindEventOnce()

public bindEventOnce($event, $callback, $priority = 0): void 

bindEventOnce creates a new event binding that fires once only

public static cacheMutatedAttributes()

public static cacheMutatedAttributes(string $class): void 

cacheMutatedAttributes extracts and cache all the mutated attributes of a class.

public static clearBootedModels()

public static clearBootedModels(): void

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

public static create()

public static create(array $attributes = []): static 

create saves a new model and return the instance.

public static created()

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

Register a created model event with the dispatcher.

public static creating()

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

Register a creating model event with the dispatcher.

public delete()

public delete(): bool|null 

delete the model from the database.

public static deleted()

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

Register a deleted model event with the dispatcher.

public static deleting()

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

Register a deleting model event with the dispatcher.

public static fetched()

public static fetched(Closure|string $callback): void 

Create a new native event for handling afterFetch().

public static fetching()

public static fetching(Closure|string $callback): void 

Create a new native event for handling beforeFetch().

public fill()

public fill(array $attributes): $this 

fill the model with an array of attributes.

public fireEvent()

public fireEvent(
    string $event,
    array $params = [],
    boolean $halt = false
): array 

fireEvent and call the listeners

public static flushEventListeners()

public static flushEventListeners(): void

flushEventListeners removes all of the event listeners for the model.

public getAllowedExtensions()

public getAllowedExtensions(): array 

getAllowedExtensions returns the allowable file extensions supported by this model.

public getAttribute()

public getAttribute(string $key): mixed 

getAttribute gets a plain attribute.

public getAttributes()

public getAttributes(): array 

getAttributes gets all of the current attributes on the model.

public getBaseFileNameAttribute()

public getBaseFileNameAttribute(): string 

getBaseFileNameAttribute returns the file name without the extension.

public static getCacheManager()

public static getCacheManager(): Illuminate\Cache\CacheManager 

getCacheManager instance.

public getDatasource()

public getDatasource(): October\Rain\Halcyon\Datasource\DatasourceInterface 

getDatasource for the model.

public getDatasourceName()

public getDatasourceName(): string 

getDatasourceName for the model.

public static getDatasourceResolver()

public static getDatasourceResolver(

): October\Rain\Halcyon\DatasourceResolverInterface 

getDatasourceResolver instance.

public getDirty()

public getDirty(): array 

getDirty get the attributes that have been changed since last sync.

public static getEventDispatcher()

public static getEventDispatcher(): Illuminate\Contracts\Events\Dispatcher 

getEventDispatcher instance.

public getFileNameParts()

public getFileNameParts($fileName = null): void

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

public getIdAttribute()

public getIdAttribute(): string 

getIdAttribute is a helper for {{ page.id }} or {{ layout.id }} twig vars Returns a semi-unique string for this object.

public getMaxNesting()

public getMaxNesting(): int 

getMaxNesting returns the maximum directory nesting allowed by this template.

public getMutatedAttributes()

public getMutatedAttributes(): array 

getMutatedAttributes gets the mutated attributes for a given instance.

public getObjectTypeDirName()

public getObjectTypeDirName(): string 

getObjectTypeDirName returns the directory name corresponding to the object type. For pages the directory name is "pages", for layouts - "layouts", etc.

public getObservableEvents()

public getObservableEvents(): array 

getObservableEvents names.

public getOriginal()

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

getOriginal gets the model's original attribute values.

public getSettingsAttribute()

public getSettingsAttribute(): array 

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

public getWrapCode()

public getWrapCode(): bool 

getWrapCode returns true if the code section will be wrapped in PHP tags.

public hasGetMutator()

public hasGetMutator(string $key): bool 

hasGetMutator determines if a get mutator exists for an attribute.

public hasSetMutator()

public hasSetMutator(string $key): bool 

hasSetMutator determines if a set mutator exists for an attribute.

public static hydrate()

public static hydrate(
    array $items,
    string|null $datasource = null
): October\Rain\Halcyon\Collection 

hydrate creates a collection of models from plain arrays.

public static initCacheItem()

public static initCacheItem(array &$cached): void

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

public isCompoundObject()

public isCompoundObject(): bool 

isCompoundObject returns true if this template supports code and settings sections.

public isDirty()

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

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

public isFillable()

public isFillable(string $key): bool 

isFillable determines if the given attribute may be mass assigned.

public isLoadedFromCache()

public isLoadedFromCache(): boolean 

isLoadedFromCache returns true if the object was loaded from the cache.

public jsonSerialize()

public jsonSerialize(): array 

jsonSerialize converts the object into something JSON serializable.

public newCollection()

public newCollection(array $models = ]): [October\Rain\Halcyon\Collection 

Create a new Halcyon Collection instance.

public newFromBuilder()

public newFromBuilder(
    array $attributes = [],
    string|null $datasource = null
): static 

newFromBuilder creates a new model instance that is existing.

public newInstance()

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

newInstance creates a new instance of the given model.

public newQuery()

public newQuery(): October\Rain\Halcyon\Builder 

Get a new query builder for the object

public offsetExists()

public offsetExists(mixed $offset): bool 

offsetExists determines if the given attribute exists.

public offsetGet()

public offsetGet(mixed $offset): mixed 

offsetGet the value for a given offset.

public offsetSet()

public offsetSet(mixed $offset, mixed $value): void 

offsetSet the value for a given offset.

public offsetUnset()

public offsetUnset(mixed $offset): void 

offsetUnset the value for a given offset.

public static on()

public static on(
    string|null $datasource = null
): October\Rain\Halcyon\Model 

on begins querying the model on a given datasource.

public static query()

public static query(): October\Rain\Halcyon\Builder 

query begins querying the model.

public removeObservableEvents()

public removeObservableEvents(array|mixed $observables): void 

removeObservableEvents name.

public static resolveDatasource()

public static resolveDatasource(
    string|null $datasource = null
): October\Rain\Halcyon\Datasource 

resolveDatasource instance.

public save()

public save(array $options = null): bool 

Save the model to the datasource.

public saveInternal()

public saveInternal(array $options = []): bool 

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

public static saved()

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

Register a saved model event with the dispatcher.

public static saving()

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

Register a saving model event with the dispatcher.

public setAttribute()

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

setAttribute sets a given attribute on the model.

public static setCacheManager()

public static setCacheManager(Illuminate\Cache\CacheManager $cache): void 

setCacheManager instance.

public setDatasource()

public setDatasource(string $name): $this 

setDatasource associated with the model.

public static setDatasourceResolver()

public static setDatasourceResolver(
    October\Rain\Halcyon\Datasource\ResolverInterface $resolver
): void 

setDatasourceResolver instance.

public static setEventDispatcher()

public static setEventDispatcher(
    Illuminate\Contracts\Events\Dispatcher $dispatcher
): void 

setEventDispatcher instance.

public setFileNameAttribute()

public setFileNameAttribute(mixed $value): void

setFileNameAttribute wjere file name should always contain an extension.

public setLoadedFromCache()

public setLoadedFromCache($value): bool 

setLoadedFromCache returns true if the object was loaded from the cache.

public setObservableEvents()

public setObservableEvents(array $observables): $this 

setObservableEvents names.

public setRawAttributes()

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

setRawAttributes sets the array of model attributes. No checking is done.

public setSettingsAttribute()

public setSettingsAttribute(mixed $value): void

setSettingsAttribute filling the settings should merge it with attributes.

public syncOriginal()

public syncOriginal(): $this 

syncOriginal attributes with the current.

public syncOriginalAttribute()

public syncOriginalAttribute(string $attribute): $this 

syncOriginalAttribute syncs a single original attribute with its current value.

public toArray()

public toArray(): array 

toArray converts the model instance to an array.

public toJson()

public toJson(int $options = 0): string 

toJson converts the model instance to JSON.

public unbindEvent()

public unbindEvent($event = null): void 

unbindEvent destroys an event binding

public static unsetCacheManager()

public static unsetCacheManager(): void 

unsetCacheManager for models.

public static unsetDatasourceResolver()

public static unsetDatasourceResolver(): void 

unsetDatasourceResolver for models.

public static unsetEventDispatcher()

public static unsetEventDispatcher(): void 

unsetEventDispatcher for models.

public update()

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

Update the model in the database.

public static updated()

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

Register an updated model event with the dispatcher.

public static updating()

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

Register an updating model event with the dispatcher.

Show inherited public methods

Inherited Public Methods

Protected Methods

protected afterBoot()

protected afterBoot(): void

afterBoot is called after the model is constructed for the first time.

protected afterCreate()

protected afterCreate(): void

afterCreate handles the "created" model event

protected afterDelete()

protected afterDelete(): void

afterDelete handles the "deleted" model event

protected afterFetch()

protected afterFetch(): void

afterFetch handles the "fetched" model event

protected afterInit()

protected afterInit(): void

afterInit is called after the model is constructed, a nicer version of overriding the __construct method.

protected afterSave()

protected afterSave(): void

afterSave handles the "saved" model event

protected afterUpdate()

protected afterUpdate(): void

afterUpdate handles the "updated" model event

protected beforeCreate()

protected beforeCreate(): void

beforeCreate handles the "creating" model event

protected beforeDelete()

protected beforeDelete(): void

beforeDelete handles the "deleting" model event

protected beforeFetch()

protected beforeFetch(): void

beforeFetch handles the "fetching" model event

protected beforeSave()

protected beforeSave(): void

beforeSave handles the "saving" model event

protected beforeUpdate()

protected beforeUpdate(): void

beforeUpdate handles the "updating" model event

protected static boot()

protected static boot(): void

boot is the "booting" method of the model.

protected bootIfNotBooted()

protected bootIfNotBooted(): void

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

protected bootNicerEvents()

protected bootNicerEvents(): void

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

protected static bootTraits()

protected static bootTraits(): void

bootTraits boots all of the bootable traits on the model.

protected static booted()

protected static booted(): void

booted performs any actions required after the model boots.

protected static booting()

protected static booting(): void

booting performs any actions required before the model boots.

protected emitterEventSortEvents()

protected emitterEventSortEvents($eventName, $combined = []): array 

emitterEventSortEvents sorts the listeners for a given event by priority

protected fillableFromArray()

protected fillableFromArray(array $attributes): array 

fillableFromArray gets the fillable attributes of a given array.

protected finishSave()

protected finishSave(array $options): void 

Finish processing on a successful save operation.

protected fireModelEvent()

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

fireModelEvent for the model.

protected getArrayableAppends()

protected getArrayableAppends(): array 

getArrayableAppends gets all of the appendable values that are arrayable.

protected getAttributeFromArray()

protected getAttributeFromArray(string $key): mixed 

getAttributeFromArray gets an attribute from the $attributes array.

protected initializeModelEvent()

protected initializeModelEvent(): void

initializeModelEvent is called every time the model is constructed.

protected initializeTraits()

protected initializeTraits(): void

initializeTraits on the model.

protected mutateAttribute()

protected mutateAttribute(string $key, mixed $value): mixed 

mutateAttribute gets the value of an attribute using its mutator.

protected mutateAttributeForArray()

protected mutateAttributeForArray(string $key, mixed $value): mixed 

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

protected originalIsNumericallyEquivalent()

protected originalIsNumericallyEquivalent(string $key): bool 

originalIsNumericallyEquivalent determine if the new and old values for a given key are numerically equivalent.

protected performDeleteOnModel()

protected performDeleteOnModel(): void

performDeleteOnModel performs the actual delete query on this model instance.

protected performInsert()

protected performInsert(
    October\Rain\Halcyon\Builder $query,
    array $options = []
): bool 

Perform a model insert operation.

protected performUpdate()

protected performUpdate(
    October\Rain\Halcyon\Builder $query,
    array $options = []
): bool 

Perform a model update operation.

protected static registerModelEvent()

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

registerModelEvent with the dispatcher.

Show inherited protected methods

Inherited Protected Methods