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

setEventDispatcher() public static method

Set the event dispatcher instance.
public static setEventDispatcher ( Illuminate\Contracts\Events\Dispatcher $dispatcher ) : void
$dispatcher Illuminate\Contracts\Events\Dispatcher
return void
    public static function setEventDispatcher(Dispatcher $dispatcher)
    {
        static::$dispatcher = $dispatcher;
    }

Usage Example

 protected function __construct()
 {
     $this->app = new Container();
     // Register mock instances with IoC container
     $config = $this->getConfig();
     $this->app->singleton('config', function () use($config) {
         return $config;
     });
     list($connector, $manager) = $this->getDatabase();
     $this->app->singleton('db.factory', function () use($connector) {
         return $connector;
     });
     $this->app->singleton('db', function () use($manager) {
         return $manager;
     });
     $auth = $this->getAuth();
     $this->app->singleton('auth', function () use($auth) {
         return $auth;
     });
     $dispatcher = new Dispatcher($this->app);
     $this->app->singleton('events', function () use($dispatcher) {
         return $dispatcher;
     });
     Model::setConnectionResolver($this->app['db']);
     Model::setEventDispatcher($this->app['events']);
 }
All Usage Examples Of Illuminate\Database\Eloquent\Model::setEventDispatcher
Model