W3cubDocs

/Laravel 5.4

HasEvents

trait HasEvents (View source)

Methods

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 saving(Closure|string $callback)

Register a saving model event with the dispatcher.

static void saved(Closure|string $callback)

Register a saved model event with the dispatcher.

static void updating(Closure|string $callback)

Register an updating model event with the dispatcher.

static void updated(Closure|string $callback)

Register an updated model event with the dispatcher.

static void creating(Closure|string $callback)

Register a creating model event with the dispatcher.

static void created(Closure|string $callback)

Register a created model event with the dispatcher.

static void deleting(Closure|string $callback)

Register a deleting model event with the dispatcher.

static void deleted(Closure|string $callback)

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.

Details

static void observe(object|string $class)

Register an observer with the Model.

Parameters

object|string $class

Return Value

void

array getObservableEvents()

Get the observable event names.

Return Value

array

$this setObservableEvents(array $observables)

Set the observable event names.

Parameters

array $observables

Return Value

$this

void addObservableEvents(array|mixed $observables)

Add an observable event name.

Parameters

array|mixed $observables

Return Value

void

void removeObservableEvents(array|mixed $observables)

Remove an observable event name.

Parameters

array|mixed $observables

Return Value

void

static void saving(Closure|string $callback)

Register a saving model event with the dispatcher.

Parameters

Closure|string $callback

Return Value

void

static void saved(Closure|string $callback)

Register a saved model event with the dispatcher.

Parameters

Closure|string $callback

Return Value

void

static void updating(Closure|string $callback)

Register an updating model event with the dispatcher.

Parameters

Closure|string $callback

Return Value

void

static void updated(Closure|string $callback)

Register an updated model event with the dispatcher.

Parameters

Closure|string $callback

Return Value

void

static void creating(Closure|string $callback)

Register a creating model event with the dispatcher.

Parameters

Closure|string $callback

Return Value

void

static void created(Closure|string $callback)

Register a created model event with the dispatcher.

Parameters

Closure|string $callback

Return Value

void

static void deleting(Closure|string $callback)

Register a deleting model event with the dispatcher.

Parameters

Closure|string $callback

Return Value

void

static void deleted(Closure|string $callback)

Register a deleted model event with the dispatcher.

Parameters

Closure|string $callback

Return Value

void

static void flushEventListeners()

Remove all of the event listeners for the model.

Return Value

void

static Dispatcher getEventDispatcher()

Get the event dispatcher instance.

Return Value

Dispatcher

static void setEventDispatcher(Dispatcher $dispatcher)

Set the event dispatcher instance.

Parameters

Dispatcher $dispatcher

Return Value

void

static void unsetEventDispatcher()

Unset the event dispatcher for models.

Return Value

void

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/5.4/Illuminate/Database/Eloquent/Concerns/HasEvents.html