public function register()
 {
     $this->registerAliases(['PluginLoader' => \KodiCMS\Plugins\Facades\PluginLoader::class]);
     $this->app->singleton('plugin.installer', function ($app) {
         return new PluginInstaller($app['db'], $app['files']);
     });
     try {
         Plugin::setConnectionResolver($this->app['db']);
         Plugin::setEventDispatcher($this->app['events']);
         $this->app['plugins.loader']->init();
     } catch (\Exception $e) {
     }
     $this->registerConsoleCommand([\KodiCMS\Plugins\Console\Commands\PluginsListCommand::class, \KodiCMS\Plugins\Console\Commands\PluginActivateCommand::class, \KodiCMS\Plugins\Console\Commands\PluginDeactivateCommand::class]);
 }
 /**
  * @return Collection|BasePluginContainer[]
  */
 protected function loadActivated()
 {
     Plugin::get()->filter(function (Plugin $model) {
         return $this->files->isDirectory($model->path);
     })->each(function (Plugin $model) {
         /** @var BasePluginContainer $pluginContainer */
         if (is_null($pluginContainer = $this->initPlugin($model->path))) {
             return;
         }
         $this->activated->put(get_class($pluginContainer), $pluginContainer);
         ModulesLoader::registerModule($pluginContainer);
         $pluginContainer->checkActivation();
         $pluginContainer->setSettings($model->settings);
     });
     return $this->activated;
 }
 /**
  * @param array $settings
  */
 public function saveSettings(array $settings)
 {
     $this->setSettings($settings);
     $model = Plugin::where('name', $this->getName())->first();
     if (!is_null($model)) {
         $model->update(['settings' => $this->getSettings()]);
     }
 }