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