argument('theme_name'); if (!is_dir(resource_path('views/visitor/' . $theme))) { throw new NotFoundHttpException('Invalid theme ' . $theme . '!'); } // load .env file $envFile = base_path('.env'); $env = file_get_contents($envFile); if (!Str::contains($env, 'THEME=')) { $env = sprintf("%s\nTHEME=%s\n", $env, $theme); } else { $env = preg_replace('/THEME=(.*)/i', 'THEME=' . $theme, $env, -1, $cnt); } // try to write content $bytesWritten = file_put_contents($envFile, $env); // check if write was successfull if (!$bytesWritten) { throw new \Exception('Cannot write to ' . base_path('.env') . '. Add THEME=' . $theme . ' to your .env file manualy.'); } // theme written $this->line('Theme successfully setup.'); $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'); } }