Przeglądaj źródła

服务包海报

jingyuzhi 4 lat temu
rodzic
commit
668f311dfe

+ 82 - 0
app/Admin/Controllers/ServebannerController.php

xqd
@@ -0,0 +1,82 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Models\Servebanner;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class ServebannerController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '服务包海报';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Servebanner());
+
+        $grid->column('id', __('Id'));
+        $grid->column('image', __('海报'))->image('',100,100);
+        $grid->column('url', __('链接'));
+        $states = [
+            'on'  => ['value' => 1, 'text' => '启用', 'color' => 'success'],
+            'off' => ['value' => 0, 'text' => '禁用', 'color' => 'danger'],
+        ];
+        $grid->column('status','状态')->switch($states);
+        $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(Servebanner::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('image', __('Image'))->image('',100,100);
+        $show->field('url', __('Url'));
+        $show->field('status', __('Status'));
+        $show->field('updated_at', __('Updated at'));
+        $show->field('created_at', __('Created at'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Servebanner());
+
+        $form->image('image', __('海报'))->rules('required' ,['required'=>'请选择图片!']);
+        $form->text('url', __('链接'));
+        $states = [
+            'off' => ['value' => 0, 'text' => '禁用', 'color' => 'danger'],
+            'on'  => ['value' => 1, 'text' => '启用', 'color' => 'success'],
+        ];
+        $form->switch('status','状态')->states($states);
+
+        return $form;
+    }
+}

+ 1 - 0
app/Admin/routes.php

xqd
@@ -18,6 +18,7 @@ Route::group([
     $router->resource('/docters', DocterController::class);
     $router->resource('/qualifications', QualificationController::class);
     $router->resource('banners', BannerController::class);
+    $router->resource('servebanners', ServebannerController::class);
 
 });
 

+ 11 - 0
app/Models/Servebanner.php

xqd
@@ -0,0 +1,11 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+
+class Servebanner extends Model
+{
+    //
+    protected $table = 'servebanners';
+}

+ 37 - 0
database/migrations/2020_11_19_094540_bm_servebanners.php

xqd
@@ -0,0 +1,37 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class BmServebanners extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        //
+        Schema::create('servebanners', function (Blueprint $table) {
+            $table->increments('id');
+            $table->string('image')->comment('图片地址');
+            $table->string('url')->comment('链接')->nullable();
+            $table->integer('status')->comment('状态');
+            $table->dateTime('created_at')->comment('创建时间');
+            $table->dateTime('updated_at')->comment('更新时间');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        //
+        Schema::drop('servebanners');
+    }
+}