@@ -13,7 +13,7 @@ class LaravelCMS extends Command
1313 * @var string
1414 */
1515 protected $ signature = 'laravelcms
16- {--a|action=initialize : initialize or install or uninstall}
16+ {--a|action=initialize : -a upgrade or -a install or -a uninstall or -a clear }
1717 {--p|table_prefix= : Default table_prefix is cms_}
1818 {--l|locale= : Default locale is en}
1919 {--s|silent=no : Silent mode yes or no}
@@ -341,6 +341,7 @@ public function initializeCms($options)
341341 file_get_contents (dirname (__FILE__ , 3 ).'/config/laravel-cms.php ' )
342342 );
343343 file_put_contents (base_path ('config/laravel-cms.php ' ), $ config_str );
344+ $ this ->line ('<fg=cyan>----> Changed db table prefix to : </><fg=yellow> ' .$ table_prefix .'</> ' );
344345 }
345346
346347 $ this ->call ('config:cache ' );
@@ -367,6 +368,8 @@ public function initializeCms($options)
367368 '--class ' => 'AlexStack\LaravelCms\CmsInquirySettingsTableSeeder ' ,
368369 ]);
369370
371+ $ this ->forBrandNewProject ();
372+
370373 $ this ->clearCache ($ options );
371374
372375 // success message
@@ -424,4 +427,42 @@ public function copyCmsFiles($source_files, $target_dir, $backup_dir, $ignore_fi
424427
425428 return true ;
426429 }
430+
431+ public function forBrandNewProject (){
432+ $ defRootRoute = <<<EOF
433+ Route::get('/', function () {
434+ return view('welcome');
435+ });
436+ EOF ;
437+ $ webRouteStr = file_get_contents (base_path ("routes/web.php " ));
438+ if ( strpos ($ webRouteStr , trim ($ defRootRoute ))!== false ){
439+ $ webRouteStr = str_replace ("::get('/', " ,"::get('/welcome', " , $ webRouteStr );
440+ file_put_contents (base_path ("routes/web.php " ), $ webRouteStr );
441+
442+ $ this ->line ('<fg=green>- Set route / to the CMS homepage</> ' );
443+
444+ $ config_str = str_replace (
445+ "'/cms-home') " ,
446+ "'/') " ,
447+ file_get_contents (dirname (__FILE__ , 3 ).'/config/laravel-cms.php ' )
448+ );
449+ file_put_contents (base_path ('config/laravel-cms.php ' ), $ config_str );
450+
451+ } else {
452+ // $this->line('<fg=green>- old route:</> '. $defRootRoute);
453+
454+ }
455+ // add a public/css/app.css for auth/login page
456+ if (!file_exists (public_path ('css ' ))) {
457+ $ target_dir = public_path ('css ' );
458+ $ backup_dir = storage_path ('app/laravel-cms/backups/css ' );
459+ $ ignore_files = [];
460+ $ source_files = glob (dirname (__FILE__ , 3 ).'/assets/publicCss/* ' );
461+
462+ // $this->line('<fg=green>- The exists public/css will backup to:</> '.$backup_dir);
463+ // $this->line('<fg=green>- </> ');
464+
465+ $ this ->copyCmsFiles ($ source_files , $ target_dir , $ backup_dir , $ ignore_files );
466+ }
467+ }
427468}
0 commit comments