Merge pull request #2802 from Haendlerbund/pr-2753/flickering-locale-factory

fix still flickering locale factory
This commit is contained in:
Jitendra Singh 2020-04-01 18:36:03 +05:30 committed by GitHub
commit 256c6fd4b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 7 deletions

View File

@ -6,12 +6,9 @@ use Webkul\Core\Models\Locale;
/** @var \Illuminate\Database\Eloquent\Factory $factory */
$factory->define(Locale::class, function (Faker $faker, array $attributes) {
$languageCode = $faker->languageCode;
$locale = Locale::query()->firstWhere('code', $languageCode);
if ($locale !== null) {
return $locale->id;
}
do {
$languageCode = $faker->languageCode;
} while (Locale::query()->where('code', $languageCode)->exists());
return [
'code' => $languageCode,
@ -22,4 +19,4 @@ $factory->define(Locale::class, function (Faker $faker, array $attributes) {
$factory->state(Category::class, 'rtl', [
'direction' => 'rtl',
]);
]);