/**
  * Return the entity name.
  *
  * @param  StreamInterface $stream
  * @param  Module $module
  * @return string
  */
 public function parse(Module $module, StreamInterface $stream)
 {
     // First, check if the user has default content
     $destination = $module->getPath();
     $entityName = strtolower(str_singular($stream->getSlug()));
     $file = $destination . "/seeders/{$entityName}" . ".php";
     return file_exists($file) ? file_get_contents($file) : '';
 }
 /**
  * Create a module record.
  *
  * @param Module $module
  * @return bool
  */
 public function create(Module $module)
 {
     $instance = $this->model->newInstance();
     $instance->namespace = $module->getNamespace();
     $instance->installed = false;
     $instance->enabled = false;
     return $instance->save();
 }
 /**
  * Return the status wrapped in a label.
  *
  * @return string
  */
 public function statusLabel()
 {
     if ($this->object->isEnabled()) {
         return '<span class="label label-success">' . trans('streams::addon.enabled') . '</span>';
     }
     if ($this->object->isInstalled()) {
         return '<span class="label label-warning">' . trans('streams::addon.disabled') . '</span>';
     }
 }
 /**
  * Handle the command.
  *
  * @param Kernel     $console
  * @param Dispatcher $events
  */
 public function handle(Kernel $console, Dispatcher $events, ModuleRepositoryInterface $modules)
 {
     $this->module->fire('uninstalling');
     $options = ['--addon' => $this->module->getNamespace()];
     $console->call('migrate:reset', $options);
     $console->call('streams:destroy', ['namespace' => $this->module->getSlug()]);
     $console->call('streams:cleanup');
     $modules->uninstall($this->module);
     $this->module->fire('uninstalled');
     $events->fire(new ModuleWasUninstalled($this->module));
 }
 /**
  * Handle the command.
  *
  * @param Kernel                    $console
  * @param AddonManager              $manager
  * @param Dispatcher                $dispatcher
  * @param ModuleRepositoryInterface $modules
  * @return bool
  */
 public function handle(Kernel $console, AddonManager $manager, Dispatcher $dispatcher, ModuleRepositoryInterface $modules)
 {
     $this->module->fire('installing');
     $options = ['--addon' => $this->module->getNamespace(), '--force' => true];
     $console->call('migrate:refresh', $options);
     $modules->install($this->module);
     $manager->register();
     if ($this->seed) {
         $console->call('db:seed', $options);
     }
     $this->module->fire('installed');
     $dispatcher->fire(new ModuleWasInstalled($this->module));
     return true;
 }
 /**
  * Get the addon routes.
  *
  * @return array
  */
 public function getRoutes()
 {
     $routes = [];
     foreach (glob($this->addon->getPath('resources/routes/*')) as $include) {
         $include = (require $include);
         if (!is_array($include)) {
             continue;
         }
         $routes = array_merge($include, $routes);
     }
     return array_merge($this->routes, $routes);
 }
 /**
  * Get the override view path.
  *
  * @param  $view
  * @return null|string
  */
 public function getOverloadPath(View $view)
 {
     /**
      * We can only overload namespaced
      * views right now.
      */
     if (!str_contains($view->getName(), '::')) {
         return null;
     }
     /**
      * Split the view into it's
      * namespace and path.
      */
     list($namespace, $path) = explode('::', $view->getName());
     $path = str_replace('.', '/', $path);
     /**
      * If the module is shorthand
      * then check to see if we have
      * an active module to use for it.
      */
     if ($namespace === 'module' && $this->module) {
         $namespace = $this->module->getNamespace();
     }
     /**
      * If the view is already in
      * the theme then skip it.
      */
     if ($namespace == 'theme' || str_is('*.theme.*', $namespace)) {
         return null;
     }
     /**
      * If the view is a streams view then
      * it's real easy to guess what the
      * override path should be.
      */
     if ($namespace == 'streams') {
         $path = $this->theme->getNamespace('streams/' . $path);
     }
     /**
      * If the view uses a dot syntax namespace then
      * transform it all into the override view path.
      */
     if ($addon = $this->addons->get($namespace)) {
         $path = $this->theme->getNamespace("addons/{$addon->getVendor()}/{$addon->getSlug()}-{$addon->getType()}/" . $path);
     }
     if ($this->view->exists($path)) {
         return $path;
     }
     /**
      * If the view uses a dot syntax namespace then
      * transform it all into the override view path.
      *
      * @deprecated since v3.0.0
      */
     if ($addon) {
         $path = $this->theme->getNamespace("addon/{$addon->getVendor()}/{$addon->getSlug()}-{$addon->getType()}/" . $path);
     }
     if ($this->view->exists($path)) {
         return $path;
     }
     return null;
 }
 /**
  * Return the vendor name.
  *
  * @param  Module $module
  * @return string
  */
 public function parse(Module $module)
 {
     return studly_case($module->getVendor());
 }
 /**
  * Set the module flags from a state object.
  *
  * @param Module $module
  * @param        $state
  */
 protected function setFlags(Module $module, $state)
 {
     $module->setEnabled($state->enabled);
     $module->setInstalled($state->installed);
 }
 /**
  * Make sure the group we are adding to
  * actually exists.
  *
  * @param array  $nav
  * @param array  $item
  * @param Module $module
  */
 protected function assureNavGroupExists(array &$nav, array $item, Module $module)
 {
     if (!isset($nav[$item['group']])) {
         $nav[$item['group']] = ['title' => $item['group'], 'active' => false, 'items' => []];
     }
     if ($module->isActive()) {
         $nav[$item['group']]['active'] = $module->isActive();
     }
 }
 /**
  * Handle the command.
  *
  * Add a default Module route, language entries etc per Module
  *
  */
 public function handle()
 {
     \Artisan::call('db:seed', ['--addon' => $this->module->getNamespace(), '--force' => true]);
 }