Browse Source

国家语言

moshaorui 4 months ago
parent
commit
ab9d7a31cc

+ 1 - 1
app/Admin/Controllers/BaseVideoController.php

@@ -43,7 +43,7 @@ class BaseVideoController extends AdminController
             $grid->column('id')->display(function () {
                 return $this->_index+1;
             });
-            $grid->column('title');
+            $grid->column('title')->width('30%');
             $grid->column('base_video_category.name',admin_trans_label('category_name'));
             $grid->column('cover_image')->display(function ($image) {
                 // 开始生成 HTML

+ 7 - 9
app/Admin/Controllers/DistAdminDistributorController.php

@@ -95,6 +95,8 @@ class DistAdminDistributorController extends AdminController
             $show->field('dist_email',admin_trans_label('email'));
             $show->field('dist_contact_number',admin_trans_label('contact_number'));
             $show->field('country');
+            $show->field('country_alpha_2');
+            $show->field('country_lang');
             $show->field('address');
 //            $show->field('domain_type')->using([0=>admin_trans_field('secondary_domain'),1=>admin_trans_field('custom_domain')]);
 //            $show->field('secondary_domain');
@@ -122,17 +124,13 @@ class DistAdminDistributorController extends AdminController
             $form->select('country')
                 ->options(BaseIso3166::selectOptions())
                 ->width(9,3)->required();
+            $form->text('country_lang')->width(9,3)->required()->help('Please enter the language code, such as en ru es');
             $form->text('address')->width(9,3);
-//            $form->radio('domain_type')->width(9,3)
-//                ->options([0=>admin_trans_field('secondary_domain'),1=>admin_trans_field('custom_domain')])
-//                ->default(0)
-//                ->required();
-//            $form->text('secondary_domain')->width(9,3)
-//                ->required()
-//                ->help('Please enter the domain name, such as demo.'.env('TOP_DOMAIN'));
-//            $form->text('custom_domain')->width(9,3)->help('Please enter the domain name, such as www.example.com');
             $form->switch('enabled')->width(9,3)->default(1);
-
+            //保存前回调
+            $form->saving(function (Form $form) {
+                $form->country_alpha_2 = BaseIso3166::getAlpha2($form->country);
+            });
             //保存后回调
             $form->saved(function (Form $form, $result) {
                 if ($form->isCreating()) {

+ 12 - 0
app/Admin/Repositories/BaseIso3166.php

@@ -23,4 +23,16 @@ class BaseIso3166 extends EloquentRepository
         }
         return $result;
     }
+
+    /*
+     * 通过英文国家名得到国家简称
+     */
+    public static function getAlpha2($countryNameEn)
+    {
+        $row = Model::where('country_name_en', $countryNameEn)->first();
+        if (empty($row)) {
+            return '';
+        }
+        return $row->country_alpha_2;
+    }
 }

+ 2 - 0
lang/zh_CN/global.php

@@ -91,6 +91,8 @@ return [
         'banner_url'            => '跳转链接',
         'template_file'         => '模板文件',
         'subtitle'              => '副标题',
+        'country_alpha_2'       => '国家简称',
+        'country_lang'          => '国家语言',
     ],
     'labels' => [
         'list'         => '列表',