protected function fireModelEvent($event, $halt = true)
{
if (!isset(static::$dispatcher)) {
return true;
}
$method = $halt ? 'until' : 'fire';
// If a custom event type has been configured for this event we'll fire that
// instead of the string version of the event. This provides for a custom
// "object-based" event more consistent with the rest of the framework.
if (isset($this->events[$event])) {
$result = static::$dispatcher->{$method}(new $this->events[$event]($this));
if (!is_null($result)) {
return $result;
}
}
// 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}: " . static::class;
return static::$dispatcher->{$method}($event, $this);
}