FIX: do not use localization service provider in CLI
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
<?php namespace App\Providers;
|
||||
|
||||
use App\Models\Language;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
|
||||
@@ -9,17 +11,27 @@ class LaravelLocalizationServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function register()
|
||||
{
|
||||
// localization is not important in running in CLI
|
||||
if (App::runningInConsole()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$languages = DB::table('languages')
|
||||
->get();
|
||||
|
||||
$supportedLocales = [
|
||||
config('app.locale') => [
|
||||
$supportedLocales = [];
|
||||
if (empty($languages)) {
|
||||
$supportedLocales[config('app.locale')] = (object)[
|
||||
'native' => env('LOCALE_NATIVE_NAME'),
|
||||
'script' => env('LOCALE_SCRIPT'),
|
||||
'name' => env('LOCALE_TRANSLATED_NAME'),
|
||||
]
|
||||
];
|
||||
'code' => config('app.locale'),
|
||||
];
|
||||
|
||||
// create default language
|
||||
Language::create((array)$supportedLocales[config('app.locale')]);
|
||||
}
|
||||
|
||||
foreach ($languages as $language) {
|
||||
$supportedLocales[$language->code] = [
|
||||
'native' => $language->native,
|
||||
|
||||
Reference in New Issue
Block a user