Browse Source

小程序 图标管理-用户端&医生端

jingyuzhi 4 years ago
parent
commit
d736638f27

+ 92 - 0
app/Admin/Controllers/IconsDoctorController.php

@@ -0,0 +1,92 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Models\Icons;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class IconsDoctorController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '图标管理——医生端';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Icons());
+
+        $grid->model()->where('type_cl','2');
+        $grid->column('id', __('Id'));
+        $grid->column('name', __('功能图标名称'));
+        $grid->column('image', __('图片'))->image('','50','50');
+        $grid->column('url', __('点击链接'));
+        $grid->column('type', __('类别'))->using([1=>'首页']);
+        $grid->column('laval', __('顺序'));
+        $status = [
+            'off' => ['value' => 0, 'text' => '禁用', 'color' => 'danger'],
+            'on'  => ['value' => 1, 'text' => '启用', 'color' => 'success'],
+        ];
+        $grid->column('status', __('状态'))->switch($status);
+        $grid->column('created_at', __('创建时间'));
+        $grid->column('updated_at', __('更新时间'));
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Icons::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('name', __('功能图标名称'));
+        $show->field('image', __('图片'))->image();
+        $show->field('url', __('点击链接'));
+        $show->field('type', __('类别'));
+        $show->field('laval', __('顺序'));
+        $show->field('status', __('状态'));
+        $show->field('created_at', __('创建时间'));
+        $show->field('updated_at', __('更新时间'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Icons());
+
+        $form->text('name', __('名称'))->rules('required' ,['required'=>'请填写名称!']);
+        $form->image('image', __('图片'))->rules('required' ,['required'=>'请选择图片!']);
+        $form->text('url', __('点击地址'))->rules('required',['requried'=>'请填写点击地址']);
+        $form->hidden('type', __('分类'))->options(Icons::$_post_type)->default(2);
+        $form->number('laval', __('顺序'));
+        $status = [
+            'off' => ['value' => 0, 'text' => '禁用', 'color' => 'danger'],
+            'on'  => ['value' => 1, 'text' => '启用', 'color' => 'success'],
+        ];
+        $form->switch('status', __('Status'))->states($status);
+
+        return $form;
+    }
+}

+ 93 - 0
app/Admin/Controllers/IconsUserController.php

@@ -0,0 +1,93 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Models\Icons;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class IconsUserController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '图标管理——用户端';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Icons());
+
+        $grid->model()->where('type_cl','1');
+        $grid->column('id', __('Id'));
+        $grid->column('name', __('功能图标名称'));
+        $grid->column('image', __('图片'))->image('','50','50');
+        $grid->column('url', __('点击链接'));
+        $grid->column('type', __('类别'))->using([1=>'首页',2=>'文章中心',3=>'个人中心']);
+        $grid->column('laval', __('顺序'));
+        $status = [
+            'off' => ['value' => 0, 'text' => '禁用', 'color' => 'danger'],
+            'on'  => ['value' => 1, 'text' => '启用', 'color' => 'success'],
+        ];
+        $grid->column('status', __('状态'))->switch($status);
+        $grid->column('created_at', __('创建时间'));
+        $grid->column('updated_at', __('更新时间'));
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Icons::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('name', __('功能图标名称'));
+        $show->field('image', __('图片'))->image();
+        $show->field('url', __('点击链接'));
+        $show->field('type', __('类别'));
+        $show->field('laval', __('顺序'));
+        $show->field('status', __('状态'));
+        $show->field('created_at', __('创建时间'));
+        $show->field('updated_at', __('更新时间'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Icons());
+
+        $form->text('name', __('名称'))->rules('required' ,['required'=>'请填写名称!']);
+        $form->image('image', __('图片'))->rules('required' ,['required'=>'请选择图片!']);
+        $form->text('url', __('点击地址'))->rules('required',['requried'=>'请填写点击地址']);
+        $form->hidden('type_cl')->default(1);
+        $form->select('type', __('分类'))->options(Icons::$_post_type)->default(1);
+        $form->number('laval', __('顺序'));
+        $status = [
+            'off' => ['value' => 0, 'text' => '禁用', 'color' => 'danger'],
+            'on'  => ['value' => 1, 'text' => '启用', 'color' => 'success'],
+        ];
+        $form->switch('status', __('Status'))->states($status);
+
+        return $form;
+    }
+}

+ 17 - 0
app/Models/Icons.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+
+class Icons extends Model
+{
+    //
+    protected $table = 'icons';
+
+    public static $_post_type = [
+        1 => '首页',
+        2 => '文章中心',
+        3 => '个人中心'
+    ];
+}

+ 39 - 0
database/migrations/2020_12_02_020655_create_icons_table.php

@@ -0,0 +1,39 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateIconsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('icons', function (Blueprint $table) {
+            $table->bigIncrements('id');
+            $table->string('name')->comment('功能图标名称');
+            $table->string('image')->comment('图片');
+            $table->string('url')->comment('点击链接');
+            $table->integer('type')->comment('类型 1.首页 2.文章中心 3.个人中心');
+            $table->integer('type_cl')->comment('分类2 1.用户端 2.客户端');
+            $table->integer('laval')->comment('排序');
+            $table->integer('status')->comment('状态 0.禁用 1.启用')->nullable(false)->unsigned();
+            $table->dateTime('created_at')->comment('创建时间');
+            $table->dateTime('updated_at')->comment('更新时间');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('icons');
+    }
+}