diff --git a/src/Commands/BreezejpCommand.php b/src/Commands/BreezejpCommand.php index 94d4be7..14f8aba 100644 --- a/src/Commands/BreezejpCommand.php +++ b/src/Commands/BreezejpCommand.php @@ -25,36 +25,71 @@ public function handle(): int (new Filesystem)->ensureDirectoryExists(lang_path()); (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/lang/', lang_path()); - $this->info('config/app.phpのlocaleをjaにします'); - // Read the contents of the file into a string - $configfile = file_get_contents(base_path('config/app.php')); + if (file_exists(base_path("config/app.php"))) { + $this->info('config/app.phpのlocaleをjaにします'); + // Read the contents of the file into a string + $configfile = file_get_contents(base_path('config/app.php')); + + // Modify the contents of the string + $configfile = str_replace("'locale' => 'en'", "'locale' => 'ja'", $configfile); + $configfile = str_replace("'faker_locale' => 'en_US'", "'faker_locale' => 'ja_JP'", $configfile); + $configfile = str_replace("'timezone' => 'UTC'", "'timezone' => 'Asia/Tokyo'", $configfile); + + // Save the modified contents back to the file + file_put_contents(base_path('config/app.php'), $configfile); + + if ($this->confirm('GitHubリポジトリにスターの御協力をお願いします🙏', true)) { + $repoUrl = 'https://github.com/askdkc/breezejp'; + + if (PHP_OS_FAMILY == 'Darwin') { + exec("open {$repoUrl}"); + } + if (PHP_OS_FAMILY == 'Windows') { + exec("start {$repoUrl}"); + } + if (PHP_OS_FAMILY == 'Linux') { + exec("xdg-open {$repoUrl}"); + } + + $this->line('Thank you! / ありがとう💓'); + } - // Modify the contents of the string - $configfile = str_replace("'locale' => 'en'", "'locale' => 'ja'", $configfile); - $configfile = str_replace("'faker_locale' => 'en_US'", "'faker_locale' => 'ja_JP'", $configfile); - $configfile = str_replace("'timezone' => 'UTC'", "'timezone' => 'Asia/Tokyo'", $configfile); + $this->info('日本語ファイルのインストールが完了しました!'); - // Save the modified contents back to the file - file_put_contents(base_path('config/app.php'), $configfile); + return self::SUCCESS; - if ($this->confirm('GitHubリポジトリにスターの御協力をお願いします🙏', true)) { - $repoUrl = 'https://github.com/askdkc/breezejp'; + } - if (PHP_OS_FAMILY == 'Darwin') { - exec("open {$repoUrl}"); - } - if (PHP_OS_FAMILY == 'Windows') { - exec("start {$repoUrl}"); - } - if (PHP_OS_FAMILY == 'Linux') { - exec("xdg-open {$repoUrl}"); - } - $this->line('Thank you! / ありがとう💓'); - } + // For Laravel 11 and above + $this->info('.envのlocaleをjaにします'); + // Read the contents of the file into a string + $configfile = file_get_contents(base_path('.env')); - $this->info('日本語ファイルのインストールが完了しました!'); + // Modify the contents of the string + $configfile = str_replace("'locale' => 'en'", "'locale' => 'ja'", $configfile); + $configfile = str_replace("'faker_locale' => 'en_US'", "'faker_locale' => 'ja_JP'", $configfile); + $configfile = str_replace("'timezone' => 'UTC'", "'timezone' => 'Asia/Tokyo'", $configfile); + + // Save the modified contents back to the file + file_put_contents(base_path('.env'), $configfile); + + if ($this->confirm('GitHubリポジトリにスターの御協力をお願いします🙏', true)) { + $repoUrl = 'https://github.com/askdkc/breezejp'; + + if (PHP_OS_FAMILY == 'Darwin') { + exec("open {$repoUrl}"); + } + if (PHP_OS_FAMILY == 'Windows') { + exec("start {$repoUrl}"); + } + if (PHP_OS_FAMILY == 'Linux') { + exec("xdg-open {$repoUrl}"); + } + + $this->line('Thank you! / ありがとう💓'); + } - return self::SUCCESS; + } }