Guest User

Untitled

a guest
Feb 25th, 2020
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.90 KB | None | 0 0
  1. if (($key === 'site_language' && Setting::get('site_language') !== $val) || ($key === 'admin_language' && Setting::get('admin_language') !== $val)) {
  2.  
  3.                     $models = [
  4.                         'product_id' => ProductTranslation::class,
  5.                         'article_id' => ArticleTranslation::class,
  6.                         'attribute_id' => AttributeTranslation::class,
  7.                         //'group_id' => AttributeGroupTranslation::class,
  8.                         'attribute_value_id' => AttributeValueTranslation::class,
  9.                         'category_id' => CategoryTranslation::class,
  10.                         'information_id' => InformationTranslation::class,
  11.                         'location_id' => LocationTranslation::class,
  12.                         'order_status_id' => OrderStatusTranslation::class,
  13.                         'price_unit_id' => PriceUnitTranslation::class,
  14.                         'stock_status_id' => StockStatusTranslation::class,
  15.                         'user_group_id' => UserGroupTranslation::class,
  16.                         'banner_id' => BannerSlide::class
  17.                     ];
  18.  
  19.                     foreach ($models as $primary_key => $model) {
  20.  
  21.                         $translates = $model::whereIn('locale', [$val, Setting::get($key)])->get();
  22.  
  23.                         foreach ($translates as $translate) {
  24.  
  25.                             if (!$translates->first(function ($row) use ($translate, $val, $primary_key) {
  26.                                 return $row->{$primary_key} == $translate->{$primary_key} && $row->locale == $val;
  27.                             })) {
  28.  
  29.                                 $eTranslate = $translate->replicate();
  30.  
  31.                                 $eTranslate->locale = $val;
  32.  
  33.                                 $eTranslate->save();
  34.                             }
  35.  
  36.                         }
  37.                     }
  38.                 }
Advertisement
Add Comment
Please, Sign In to add comment