FIX: use LaravelLocalizationServiceProvider in CLI, but do not throw exceptions when table languages is missing
This commit is contained in:
@@ -11,17 +11,16 @@ class LaravelLocalizationServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function register()
|
||||
{
|
||||
// localization is not important in running in CLI
|
||||
if (App::runningInConsole()) {
|
||||
return;
|
||||
try {
|
||||
$languages = DB::table('languages')
|
||||
->get();
|
||||
} catch (\Exception $e) {
|
||||
$languages = [];
|
||||
}
|
||||
|
||||
$languages = DB::table('languages')
|
||||
->get();
|
||||
|
||||
$supportedLocales = [];
|
||||
if (empty($languages)) {
|
||||
$supportedLocales[config('app.locale')] = (object)[
|
||||
$supportedLocales[config('app.locale')] = [
|
||||
'native' => env('LOCALE_NATIVE_NAME'),
|
||||
'script' => env('LOCALE_SCRIPT'),
|
||||
'name' => env('LOCALE_TRANSLATED_NAME'),
|
||||
@@ -29,7 +28,11 @@ class LaravelLocalizationServiceProvider extends ServiceProvider
|
||||
];
|
||||
|
||||
// create default language
|
||||
Language::create((array)$supportedLocales[config('app.locale')]);
|
||||
try {
|
||||
Language::create($supportedLocales[config('app.locale')]);
|
||||
} catch (\Exception $e) {
|
||||
// ignore, table languages probably does not exist.
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($languages as $language) {
|
||||
|
||||
Reference in New Issue
Block a user