ソースを参照

feat: 更新路由 配置 个人设置

igb 5 ヶ月 前
コミット
1d4077ad34

+ 106 - 0
app/Distributor/Controllers/AuthController.php

@@ -3,9 +3,115 @@
 namespace App\Distributor\Controllers;
 
 use Dcat\Admin\Http\Controllers\AuthController as BaseAuthController;
+use Dcat\Admin\Admin;
+use Dcat\Admin\Form;
+use Dcat\Admin\Http\Repositories\Administrator;
+use Dcat\Admin\Layout\Content;
+use Illuminate\Http\Request;
+
 
 class AuthController extends BaseAuthController
 {
     protected $view = 'distributor.pages.login';
 
+    public function getSetting(Content $content)
+    {
+        $form = $this->settingForm();
+        $form->tools(
+            function (Form\Tools $tools) {
+                $tools->disableList();
+            }
+        );
+
+        return $content
+            ->title(trans('admin.user_setting'))
+            ->body($form->edit(Admin::user()->getKey()));
+
+    }
+
+    /**
+     * Model-form for user setting.
+     *
+     * @return Form
+     */
+    protected function settingForm()
+    {
+
+        return new Form(new Administrator(), function (Form $form) {
+            $form->action(admin_url('auth/setting'));
+            $form->disableCreatingCheck();
+            $form->disableEditingCheck();
+            $form->disableViewCheck();
+
+            $form->tools(function (Form\Tools $tools) {
+                $tools->disableView();
+                $tools->disableDelete();
+            });
+
+            $form->display('username', trans('admin.username'));
+            $form->text('name', trans('admin.name'))->required();
+            //$form->image('avatar', trans('admin.avatar'))->autoUpload();
+
+            $form->password('old_password', trans('admin.old_password'));
+
+            $form->password('password', trans('admin.password'))
+                ->minLength(5)
+                ->maxLength(20)
+                ->customFormat(function ($v) {
+                    if ($v == $this->password) {
+                        return;
+                    }
+
+                    return $v;
+                });
+            $form->password('password_confirmation', trans('admin.password_confirmation'))->same('password');
+
+            $form->ignore(['password_confirmation', 'old_password']);
+
+            // 添加语言选择的下拉框
+            $form->select('language', trans('admin.language'))
+                ->options(config('app.languages'))
+                ->default('en')
+                ->required();;  // 设置默认语言
+
+            $form->saving(function (Form $form) {
+                if ($form->password && $form->model()->password != $form->password) {
+                    $form->password = bcrypt($form->password);
+                }
+
+                if (! $form->password) {
+                    $form->deleteInput('password');
+                }
+            });
+
+            $form->saved(function (Form $form) {
+                return $form
+                    ->response()
+                    ->success(trans('admin.update_succeeded'))
+                    //->redirect('/');
+                    ->script('location.reload();');//保存成功后刷新页面
+            });
+
+//            // 在从数据库中取出记录时,如果 language 为空,则默认给它一个值
+//            $form->model()->language = $form->model()->language ?: 'en';
+
+        });
+    }
+
+
+    protected function sendLoginResponse(Request $request)
+    {
+        $request->session()->regenerate();
+
+        $path = $this->getRedirectPath();
+
+
+        return $this->response()
+            ->success(trans('admin.login_successful'))
+            ->locationToIntended($path)
+            ->locationIf(Admin::app()->getEnabledApps(), $path)
+            ->send();
+    }
+
+
 }

+ 13 - 1
app/Distributor/routes.php

@@ -17,8 +17,20 @@ Route::group([
     'middleware' => config('admin.route.middleware'),
 ], function (Router $router) {
 
-    $router->get('/', 'HomeController@index');
 
+    //主页
+    $router->get('/', 'HomeController@index');
+    //产品
+    $router->get('base-product/parameter', 'DistProductController@parameter');
+    $router->resource('dist-product', 'DistProductController');
+    //分类
+    $router->resource('product-category', 'DistProductCategoryController');
+    //参数
+    $router->resource('product-parameter', 'DistProductParameterController');
+    //视频分类
+    $router->resource('video-category', 'DistVideoCategoryController');
+    //视频管理
+    $router->resource('dist-video', 'DistVideoController');
 });
 
 

+ 3 - 3
config/distributor.php

@@ -22,7 +22,7 @@ return [
     | `img` tag, eg '<img src="http://logo-url" alt="Admin logo">'.
     |
     */
-    'logo' => '<img src="/vendor/dcat-admin/images/logo.png" width="35"> &nbsp;Dcat Admin',
+    'logo' => 'Dist Manager',
 
     /*
     |--------------------------------------------------------------------------
@@ -264,8 +264,8 @@ return [
 
         // Image and file upload path under the disk above.
         'directory' => [
-            'image' => 'images',
-            'file'  => 'files',
+            'image' => 'dist_images',
+            'file'  => 'dist_files',
         ],
 
         'oss_image' => [