HasEvents

Properties

protected

$dispatchesEvents array

The event map for the model.

Allows for object-based events for native Eloquent events.

Default: []
protected

$observables array

User exposed observable events.

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

Default: []

Methods

public static

observe ( $classes ) : void

Register observers with the model.

Parameters

  • $classes object|array|string
protected

registerObserver ( $class ) : void

Register a single observer with the model.

Parameters

  • $class object|string
private

resolveObserverClassName ( $class ) : string

Resolve the observer's class name from an object or string.

Parameters

  • $class object|string
public

getObservableEvents ( ) : array

Get the observable event names.

public

setObservableEvents ( array $observables ) : $this

Set the observable event names.

Parameters

  • $observables array
public

addObservableEvents ( $observables ) : void

Add an observable event name.

Parameters

  • $observables array|mixed
public

removeObservableEvents ( $observables ) : void

Remove an observable event name.

Parameters

  • $observables array|mixed
protected static

registerModelEvent ( $event , $callback ) : void

Register a model event with the dispatcher.

Parameters

protected

fireModelEvent ( $event , $halt ) : mixed

Fire the given event for the model.

Parameters

  • $event string
  • $halt bool
protected

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

Fire a custom model event for the given event.

Parameters

  • $event string
  • $method string
protected

filterModelEventResults ( $result ) : mixed

Filter the model event results.

Parameters

  • $result mixed
public static

retrieved ( $callback ) : void

Register a retrieved model event with the dispatcher.

Parameters

public static

saving ( $callback ) : void

Register a saving model event with the dispatcher.

Parameters

public static

saved ( $callback ) : void

Register a saved model event with the dispatcher.

Parameters

public static

updating ( $callback ) : void

Register an updating model event with the dispatcher.

Parameters

public static

updated ( $callback ) : void

Register an updated model event with the dispatcher.

Parameters

public static

creating ( $callback ) : void

Register a creating model event with the dispatcher.

Parameters

public static

created ( $callback ) : void

Register a created model event with the dispatcher.

Parameters

public static

replicating ( $callback ) : void

Register a replicating model event with the dispatcher.

Parameters

public static

deleting ( $callback ) : void

Register a deleting model event with the dispatcher.

Parameters

public static

deleted ( $callback ) : void

Register a deleted model event with the dispatcher.

Parameters

public static

flushEventListeners ( ) : void

Remove all the event listeners for the model.

public static

getEventDispatcher ( ) : Dispatcher

Get the event dispatcher instance.

public static

setEventDispatcher ( Dispatcher $dispatcher ) : void

Set the event dispatcher instance.

Parameters

public static

unsetEventDispatcher ( ) : void

Unset the event dispatcher for models.

public static

withoutEvents ( callable $callback ) : mixed

Execute a callback without firing any model events for any model type.

Parameters

  • $callback callable