Browse Source

供应商修改

moshaorui 5 months ago
parent
commit
98f2d5da78

+ 24 - 15
app/Admin/Controllers/DistAdminDistributorController.php

@@ -70,6 +70,10 @@ class DistAdminDistributorController extends AdminController
     {
         return Show::make($id, new DistAdminDistributor(), function (Show $show) {
             $show->field('id');
+            $show->field('company_name','Company Name');
+            $show->field('company_address','Company Address');
+            $show->field('site_name');
+            $show->field('level_domain');
             $show->field('country');
             $show->field('contact_number');
             $show->field('service_hotline');
@@ -79,14 +83,12 @@ class DistAdminDistributorController extends AdminController
             $show->field('youtube');
             $show->field('linkedin');
             $show->field('tiktok');
-            $show->field('site_name');
-            $show->field('level_domain');
             $show->field('remark');
-            $show->field('company_address');
-            $show->field('company_name');
-            $show->field('enabled');
+            $show->width(6)->field('enabled')->using(config('dictionary.enabled'));
             $show->field('created_at');
             $show->field('updated_at');
+            // 按钮
+            $show->disableDeleteButton();
         });
     }
 
@@ -99,10 +101,11 @@ class DistAdminDistributorController extends AdminController
     {
         return Form::make(new DistAdminDistributor(), function (Form $form) {
             $form->display('id');
-            $form->text('company_name');
-            $form->text('site_name');
-            $form->text('level_domain');
-            $form->text('country');
+            $form->text('company_name', 'Company Name')->required();
+            $form->text('company_address','Company Address');
+            $form->text('site_name')->required();
+            $form->text('level_domain')->required();
+            $form->text('country')->required();
             $form->text('contact_number');
             $form->text('service_hotline');
             $form->text('whats_app');
@@ -111,15 +114,21 @@ class DistAdminDistributorController extends AdminController
             $form->text('youtube');
             $form->text('linkedin');
             $form->text('tiktok');
-            $form->switch('enabled')->default(1);
-            $form->text('company_address');
             $form->textarea('remark');
-            $form->display('created_at');
-            $form->display('updated_at');
+            $form->switch('enabled')->default(1);
             //保存后回调
             $form->saved(function (Form $form, $result) {
-
-
+                if ($form->isCreating()) {
+                    $newId = $form->getKey();
+                    $distProductCategory = new DistProductCategory();
+                    $distProductCategory->create([
+                        'parent_id' => 0,
+                        'name' => 'Default Category',
+                        'order' => 0,
+                        'enabled' => 1,
+                        'dist_id'=>$newId,
+                    ]);
+                }
             });
         });
 

+ 15 - 17
app/Admin/Controllers/DistAdminUserController.php

@@ -70,13 +70,22 @@ class DistAdminUserController extends AdminController
     protected function detail($id)
     {
         return Show::make($id, DistAdminUser::with(['distributor']), function (Show $show) {
-            $show->row(function (Show\Row $show) {
+            $show->row(function ($show) {
                 $show->width(6)->field('id');
                 $show->width(6)->field('username');
                 $show->width(6)->field('name','name');
-                $show->width(6)->field('info.site_name','Site Name');
-                $show->width(6)->field('distributor.level_domain','Level Domain');
+                $show->width(6)->field('language')->using(config('dictionary.languages'));
+                $show->width(6)->field('enabled')->using(config('dictionary.enabled'));
+                $show->width(6)->field('created_at');
+                $show->width(6)->field('updated_at');
+            });
+
+
+            $show->row(function ($show) {
                 $show->width(6)->field('distributor.company_name', 'Company Name');
+                $show->width(6)->field('distributor.company_address','Company Address');
+                $show->width(6)->field('distributor.site_name','Site Name');
+                $show->width(6)->field('distributor.level_domain','Level Domain');
                 $show->width(6)->field('distributor.country','Country');
                 $show->width(6)->field('distributor.contact_number','Contact Number');
                 $show->width(6)->field('distributor.service_hotline','Service Hotline');
@@ -86,13 +95,11 @@ class DistAdminUserController extends AdminController
                 $show->width(6)->field('distributor.youtube','Youtube');
                 $show->width(6)->field('distributor.linkedin','Linkedin');
                 $show->width(6)->field('distributor.tiktok','Tiktok');
-                $show->width(6)->field('language')->using(config('dictionary.languages'));
-                $show->width(6)->field('enabled')->using(config('dictionary.enabled'));
-                $show->width(6)->field('distributor.company_address','Company Address');
-                $show->width(6)->field('created_at');
-                $show->width(6)->field('updated_at');
                 $show->width(6)->field('distributor.remark','Remark');
             });
+
+            // 按钮
+            $show->disableDeleteButton();
         });
     }
 
@@ -141,15 +148,6 @@ class DistAdminUserController extends AdminController
                         return $form->response()->error('Failed to save data');
                     }
                     DistAdminUser::addRoleUser($newId, config('dictionary.dist_role_id'));//分销商角色ID 2
-                    //分配默认分类
-//                    $distProductCategory = new DistProductCategory();
-//                    $distProductCategory->create([
-//                        'parent_id' => 0,
-//                        'name' => 'Default Category',
-//                        'order' => 0,
-//                        'enabled' => 1,
-//                        'dist_id'=>$newId,
-//                    ]);
                 }
             });
         });