Illuminate\Database\Eloquent\Model::getEventDispatcher PHP Method

getEventDispatcher() public static method

Get the event dispatcher instance.
public static getEventDispatcher ( ) : Illuminate\Contracts\Events\Dispatcher
return Illuminate\Contracts\Events\Dispatcher
    public static function getEventDispatcher()
    {
        return static::$dispatcher;
    }

Usage Example

 /**
  * Fire the given event for the given model.
  *
  * @param  string  $event
  * @param  bool    $halt
  * @return mixed
  */
 protected function fireModelEvent(Model $model, $event, $halt = true)
 {
     $dispatcher = $model->getEventDispatcher();
     if (is_null($dispatcher)) {
         return true;
     }
     // We will append the names of the class to the event to distinguish it from
     // other model events that are fired, allowing us to listen on each model
     // event set individually instead of catching event for all the models.
     $event = "eloquent.{$event}: " . get_class($model);
     $method = $halt ? 'until' : 'fire';
     return $dispatcher->{$method}($event, $model);
 }
Model