Documentation

HasEvents

Table of Contents

$dispatchesEvents  : array<string|int, mixed>
The event map for the model.
$observables  : array<string|int, mixed>
User exposed observable events.
addObservableEvents()  : void
Add an observable event name.
created()  : void
Register a created model event with the dispatcher.
creating()  : void
Register a creating model event with the dispatcher.
deleted()  : void
Register a deleted model event with the dispatcher.
deleting()  : void
Register a deleting model event with the dispatcher.
flushEventListeners()  : void
Remove all of the event listeners for the model.
getEventDispatcher()  : Dispatcher
Get the event dispatcher instance.
getObservableEvents()  : array<string|int, mixed>
Get the observable event names.
observe()  : void
Register an observer with the Model.
removeObservableEvents()  : void
Remove an observable event name.
retrieved()  : void
Register a retrieved model event with the dispatcher.
saved()  : void
Register a saved model event with the dispatcher.
saving()  : void
Register a saving model event with the dispatcher.
setEventDispatcher()  : void
Set the event dispatcher instance.
setObservableEvents()  : $this
Set the observable event names.
unsetEventDispatcher()  : void
Unset the event dispatcher for models.
updated()  : void
Register an updated model event with the dispatcher.
updating()  : void
Register an updating model event with the dispatcher.
filterModelEventResults()  : mixed
Filter the model event results.
fireCustomModelEvent()  : mixed|null
Fire a custom model event for the given event.
fireModelEvent()  : mixed
Fire the given event for the model.
registerModelEvent()  : void
Register a model event with the dispatcher.

Properties

$dispatchesEvents

The event map for the model.

protected array<string|int, mixed> $dispatchesEvents = []

Allows for object-based events for native Eloquent events.

$observables

User exposed observable events.

protected array<string|int, mixed> $observables = []

These are extra user-defined events observers may subscribe to.

Methods

addObservableEvents()

Add an observable event name.

public addObservableEvents(array<string|int, mixed>|mixed $observables) : void
Parameters
$observables : array<string|int, mixed>|mixed
Return values
void

created()

Register a created model event with the dispatcher.

public static created(Closure|string $callback) : void
Parameters
$callback : Closure|string
Return values
void

creating()

Register a creating model event with the dispatcher.

public static creating(Closure|string $callback) : void
Parameters
$callback : Closure|string
Return values
void

deleted()

Register a deleted model event with the dispatcher.

public static deleted(Closure|string $callback) : void
Parameters
$callback : Closure|string
Return values
void

deleting()

Register a deleting model event with the dispatcher.

public static deleting(Closure|string $callback) : void
Parameters
$callback : Closure|string
Return values
void

flushEventListeners()

Remove all of the event listeners for the model.

public static flushEventListeners() : void
Return values
void

getObservableEvents()

Get the observable event names.

public getObservableEvents() : array<string|int, mixed>
Return values
array<string|int, mixed>

observe()

Register an observer with the Model.

public static observe(object|string $class) : void
Parameters
$class : object|string
Return values
void

removeObservableEvents()

Remove an observable event name.

public removeObservableEvents(array<string|int, mixed>|mixed $observables) : void
Parameters
$observables : array<string|int, mixed>|mixed
Return values
void

retrieved()

Register a retrieved model event with the dispatcher.

public static retrieved(Closure|string $callback) : void
Parameters
$callback : Closure|string
Return values
void

saved()

Register a saved model event with the dispatcher.

public static saved(Closure|string $callback) : void
Parameters
$callback : Closure|string
Return values
void

saving()

Register a saving model event with the dispatcher.

public static saving(Closure|string $callback) : void
Parameters
$callback : Closure|string
Return values
void

setEventDispatcher()

Set the event dispatcher instance.

public static setEventDispatcher(Dispatcher $dispatcher) : void
Parameters
$dispatcher : Dispatcher
Return values
void

setObservableEvents()

Set the observable event names.

public setObservableEvents(array<string|int, mixed> $observables) : $this
Parameters
$observables : array<string|int, mixed>
Return values
$this

unsetEventDispatcher()

Unset the event dispatcher for models.

public static unsetEventDispatcher() : void
Return values
void

updated()

Register an updated model event with the dispatcher.

public static updated(Closure|string $callback) : void
Parameters
$callback : Closure|string
Return values
void

updating()

Register an updating model event with the dispatcher.

public static updating(Closure|string $callback) : void
Parameters
$callback : Closure|string
Return values
void

filterModelEventResults()

Filter the model event results.

protected filterModelEventResults(mixed $result) : mixed
Parameters
$result : mixed
Return values
mixed

fireCustomModelEvent()

Fire a custom model event for the given event.

protected fireCustomModelEvent(string $event, string $method) : mixed|null
Parameters
$event : string
$method : string
Return values
mixed|null

fireModelEvent()

Fire the given event for the model.

protected fireModelEvent(string $event[, bool $halt = true ]) : mixed
Parameters
$event : string
$halt : bool = true
Return values
mixed

registerModelEvent()

Register a model event with the dispatcher.

protected static registerModelEvent(string $event, Closure|string $callback) : void
Parameters
$event : string
$callback : Closure|string
Return values
void

Search results