Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (($key === 'site_language' && Setting::get('site_language') !== $val) || ($key === 'admin_language' && Setting::get('admin_language') !== $val)) {
- $models = [
- 'product_id' => ProductTranslation::class,
- 'article_id' => ArticleTranslation::class,
- 'attribute_id' => AttributeTranslation::class,
- //'group_id' => AttributeGroupTranslation::class,
- 'attribute_value_id' => AttributeValueTranslation::class,
- 'category_id' => CategoryTranslation::class,
- 'information_id' => InformationTranslation::class,
- 'location_id' => LocationTranslation::class,
- 'order_status_id' => OrderStatusTranslation::class,
- 'price_unit_id' => PriceUnitTranslation::class,
- 'stock_status_id' => StockStatusTranslation::class,
- 'user_group_id' => UserGroupTranslation::class,
- 'banner_id' => BannerSlide::class
- ];
- foreach ($models as $primary_key => $model) {
- $translates = $model::whereIn('locale', [$val, Setting::get($key)])->get();
- foreach ($translates as $translate) {
- if (!$translates->first(function ($row) use ($translate, $val, $primary_key) {
- return $row->{$primary_key} == $translate->{$primary_key} && $row->locale == $val;
- })) {
- $eTranslate = $translate->replicate();
- $eTranslate->locale = $val;
- $eTranslate->save();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment