October\Rain\Halcyon\Concerns\HasEvents
Overview
HasEvents concern for a model
Protected Properties
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.
Public Methods
public addObservableEvents()
public addObservableEvents(array|mixed $observables): void
addObservableEvents name.
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 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 static flushEventListeners()
public static flushEventListeners(): void
flushEventListeners removes all of the event listeners for the model.
public static getEventDispatcher()
public static getEventDispatcher(): Illuminate\Contracts\Events\Dispatcher
getEventDispatcher instance.
public getObservableEvents()
public getObservableEvents(): array
getObservableEvents names.
public removeObservableEvents()
public removeObservableEvents(array|mixed $observables): void
removeObservableEvents name.
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 static setEventDispatcher()
public static setEventDispatcher(
Illuminate\Contracts\Events\Dispatcher $dispatcher
): void
setEventDispatcher instance.
public setObservableEvents()
public setObservableEvents(array $observables): $this
setObservableEvents names.
public static unsetEventDispatcher()
public static unsetEventDispatcher(): void
unsetEventDispatcher for models.
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.
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 bootNicerEvents()
protected bootNicerEvents(): void
bootNicerEvents binds some nicer events to this model, in the format of method overrides.
protected fireModelEvent()
protected fireModelEvent(string $event, bool $halt = true): mixed
fireModelEvent for the model.
protected initializeModelEvent()
protected initializeModelEvent(): void
initializeModelEvent is called every time the model is constructed.
protected static registerModelEvent()
protected static registerModelEvent(
string $event,
Closure|string $callback,
int $priority = 0
): void
registerModelEvent with the dispatcher.