Bladeren bron

保险协议库的创建

ChenWuJie 4 jaren geleden
bovenliggende
commit
151fb1c4f6

+ 73 - 0
app/Admin/Controllers/ServicePacksManagment/InsuranceAgreementController.php

xqd
@@ -0,0 +1,73 @@
+<?php
+
+namespace App\Admin\Controllers\ServicePacksManagment;
+
+use App\Models\InsuranceAgreement;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class InsuranceAgreementController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '保险协议列表';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new InsuranceAgreement());
+        $grid->disableBatchActions();
+        $grid->disableCreateButton();
+        $grid->actions(function ($actions){
+           $actions->disableView();
+        });
+        $grid->column('id', __('Id'));
+        $grid->column('name', __('协议名称'));
+        $grid->column('content', __('协议内容'))->limit(20,'...');
+        $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
+     */
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new InsuranceAgreement());
+
+        $form->text('name', __('协议名称'));
+        $form->editor('content', __('协议内容'));
+        $status = [
+            'off' => ['value' => 0, 'text' => '禁用', 'color' => 'danger'],
+            'on'  => ['value' => 1, 'text' => '启用', 'color' => 'success'],
+        ];
+        $form->switch('status', __('状态'))->states($status)->default(1);
+
+        return $form;
+    }
+}

+ 1 - 0
app/Admin/Controllers/ServicePacksManagment/ServicePacksController.php

xqd
@@ -69,6 +69,7 @@ class ServicePacksController extends AdminController
 
         $grid->column('image','图片')->lightbox(['width' =>'', 'height' => 30]);
         $grid->column('is_need_insure', __('是否包含保险'))->using([0=>'不包含',1=>'包含']);
+        $grid->column('insuranceagreement.name', __('保险协议名称'));
         $grid->column('phone_minutes', __('电话次数'));
         $grid->column('chat_num', __('图文次数'));
         $grid->column('appoint_num', __('门诊次数'));

+ 2 - 0
app/Admin/routes.php

xqd
@@ -67,6 +67,8 @@ Route::group([
     //开通记录
     $router->resource('open_pack', ServicePacksManagment\OpenPackController::class);
 
+    $router->resource('insurance_agreements', ServicePacksManagment\InsuranceAgreementController::class);
+
     $router->resource('/setting', 'Config\ConfigController');
     $router->get('/setting_form', 'Config\FormController@form');
     $router->post('/setting_form_save', 'Config\FormController@setting_form_save');

+ 11 - 0
app/Models/InsuranceAgreement.php

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

+ 3 - 0
app/Models/ServicePack.php

xqd
@@ -29,4 +29,7 @@ class ServicePack extends BaseModel
 
         return $data;
     }
+    public function insuranceagreement(){
+        return $this->hasOne(InsuranceAgreement::class,'id','agreement_id');
+    }
 }