argument('template'); $templatePath = app_path('../templates/' . $template); if (!is_dir($templatePath) || !file_exists($templatePath . '/config.php')) { throw new NotFoundHttpException('Invalid template ' . $template . '!'); } // try to find currently installed template $current = Module::where('is_template', true) ->first(); // install template $config = @include $templatePath . '/config.php'; $config['staticName'] = $template; if ($current) { $info = json_decode($current->module_settings); $this->line('Template is already installed. Currently using template ' . trans($current->name) . ' located in /templates/' . $info->staticName.'.'); $confirm = $this->ask('Uninstall it and install *' . trans($config['name']) . '*? All data associated with installed template will be lost! [y/n]'); if ($confirm === 'y') { $this->line('Uninstalling ' . $current->name . '.'); $current->uninstall(); } else { $this->line('Aborting installation.'); return; } } try { Module::install($config['name'], $config['alias'], $config['description'], $config['handler'], false, $config); } catch (\Exception $e) { $this->error('Cannot install template ' . $template . '. Message: ' . $e->getMessage()); return; } // theme written $this->line('Template successfully set up.'); $this->line(''); $this->line(' ** PUBLISHING ASSETS AND VIEWS **'); // publish assets and views for module and theme $this->call('vendor:publish', ['--tag' => ['public-assets'], '--force' => true]); $this->call('vendor:publish', ['--tag' => ['module-views'], '--force' => true]); $this->call('vendor:publish'); } }