Browse Source

Merge branch 'master' of ssh://git.9026.com:2212/swdz-WangHaijun/BaoMa

zilong 4 years ago
parent
commit
707bc75c32

+ 21 - 0
app/Admin/Actions/backstage/Pass.php

xqd
@@ -0,0 +1,21 @@
+<?php
+
+namespace App\Admin\Actions\backstage;
+
+use App\Models\DocterOrganization;
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class Pass extends RowAction
+{
+    public $name = '通过';
+
+    public function handle(Model $model)
+    {
+//         $model ...
+//        dd($model);
+        DocterOrganization::where('id',$model->id)->update(['state'=>2]);
+        return $this->response()->success('审核通过')->refresh();
+    }
+
+}

+ 19 - 0
app/Admin/Actions/backstage/Refuse.php

xqd
@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Admin\Actions\backstage;
+use App\Models\DocterOrganization;
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class Refuse extends RowAction
+{
+    public $name = '驳回';
+
+    public function handle(Model $model)
+    {
+        // $model ...
+        DocterOrganization::where('id',$model->id)->update(['state'=>3]);
+        return $this->response()->success('审核拒绝')->refresh();
+    }
+
+}

+ 19 - 0
app/Admin/Actions/backstage/Revoke.php

xqd
@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Admin\Actions\backstage;
+use App\Models\DocterOrganization;
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Database\Eloquent\Model;
+
+class Revoke extends RowAction
+{
+    public $name = '撤销';
+
+    public function handle(Model $model)
+    {
+        // $model ...
+        DocterOrganization::where('id',$model->id)->update(['state'=>0]);
+        return $this->response()->success('审核撤销')->refresh();
+    }
+
+}

+ 101 - 0
app/Admin/Controllers/ApproveController.php

xqd
@@ -0,0 +1,101 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Admin\Actions\backstage\Pass;
+use App\Admin\Actions\backstage\Refuse;
+use App\Admin\Actions\backstage\Revoke;
+use App\Models\Docter;
+use App\Models\DocterOrganization;
+use App\Models\Office;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class ApproveController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '认证列表';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new DocterOrganization());
+        $grid ->model()->where('state','>=','1');
+        $grid->column('id', __('Id'));
+        $grid->column('docter.id', __('医生ID'));
+        $grid->column('docter.name', __('名字'));
+        $grid->column('docter.sex', __('性别'))->using([0=>'未知',1=>'男',2=>'女']);
+        $grid->column('docter.card_id', __('身份证'));
+        $grid->column('organization.name', __('机构'));
+        $grid->column('office.name', __('科室'));
+        $grid->column('qualification.name', __('医生资质'));
+        $grid->column('state', __('状态'))->using([1=>'待审核',2=>'已认证',3=>'已驳回']);
+
+        $grid->actions(function ($actions) {
+            $actions->add(new Pass());
+            $actions->add(new Refuse());
+            $actions->add(new Revoke());
+        });
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+
+        $show = new Show(DocterOrganization::findOrFail($id));
+        $show->field('id', __('Id'));
+        $show->field('docter.id', __('医生ID'));
+        $show->field('docter.name', __('名字'));
+        $show->field('docter.sex', __('性别'))->using([0=>'未知',1=>'男',2=>'女']);
+        $show->field('docter.card_id', __('身份证'));
+        $show->field('organization.name', __('机构'));
+        $show->field('office.name', __('科室'));
+        $show->field('qualification.name', __('医生资质'));
+//        $show->field('docter.card_photo', __('身份证正反面'))->as(function ($id){
+////            dd($id);
+//            $imgs = explode(',',$id);
+//            $html = '';
+//            foreach ($imgs as $val){
+//                $html .='img src="'.$val.'"';
+//            }
+//            return "<{$html}>";
+////            return json_decode($id,true);
+//        });
+        $show->field('docter.card_photo', __('身份证正反面'))->image();
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new DocterOrganization());
+
+        $form->number('docter_id', __('Docter id'));
+        $form->number('organization_id', __('Organization id'));
+        $form->number('offices_id', __('Offices id'));
+        $form->number('qualifications_id', __('Qualifications id'));
+        $form->number('state', __('State'));
+
+        return $form;
+    }
+}

+ 77 - 0
app/Admin/Controllers/ArticleController.php

xqd
@@ -0,0 +1,77 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Models\Article;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class ArticleController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = 'Article';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Article());
+
+        $grid->column('id', __('Id'));
+        $grid->column('type', __('分类'));
+        $grid->column('title', __('标题'))->limit(10,'...')->width(100);
+        $grid->column('content', __('内容'))->limit(20,'...')->width(200);
+        $grid->column('banner_url', __('图片'))->image('',50,50);
+        $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(Article::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('type', __('分类'));
+        $show->field('title', __('标题'));
+        $show->field('content', __('内容'));
+        $show->field('banner_url', __('图片'))->image('',100,100);
+        $show->field('created_at', __('Created at'));
+        $show->field('updated_at', __('Updated at'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Article());
+
+        $form->select('type', __('分类'))->options(Article::$_post_type)->default(1);
+        $form->text('title', __('标题'))->rules('required|min:3|max:255',['required'=>'请填写标题','min'=>'标题字符不能少于3个','max'=>'标题长度过长']);
+        $form->textarea('content', __('内容'))->rules('required|min:3',['required'=>'请填写标题','min'=>'标题字符不能少于3个']);
+        $form->image('banner_url', __('图片'))->rules('required' ,['required'=>'请选择图片!']);
+
+        return $form;
+    }
+}

+ 95 - 0
app/Admin/Controllers/BannerController.php

xqd
@@ -0,0 +1,95 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Models\Banner;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class BannerController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = 'Banner';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Banner());
+
+        $grid->column('id', __('Id'));
+        $grid->column('image', __('图片'))->image('',100,100);
+        $grid->column('type','类型')->using([1=>'用户端',2=>'医生端']);
+        $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', __('更新时间'));
+        $grid->filter(function($filter){
+
+            // Remove the default id filter
+            $filter->disableIdFilter();
+
+            // Add a column filter
+            $type = [''=>'全部'];
+            $type = array_merge($type,Banner::$_post_type);
+            $filter->equal('type', '类别')->select(Banner::$_post_type);
+
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Banner::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 Banner());
+
+        $form->select('type' ,__('分类'))->options(Banner::$_post_type)->default('1');
+        $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;
+    }
+}

+ 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;
+    }
+}

+ 4 - 0
app/Admin/routes.php

xqd
@@ -17,5 +17,9 @@ Route::group([
     $router->resource('/organizations', OrganizationController::class);
     $router->resource('/docters', DocterController::class);
     $router->resource('/qualifications', QualificationController::class);
+    $router->resource('/docters_approve', ApproveController::class);
+    $router->resource('banners', BannerController::class);
+    $router->resource('servebanners', ServebannerController::class);
+    $router->resource('articles', ArticleController::class);
 });
 

+ 11 - 5
app/Models/Article.php

xqd
@@ -11,14 +11,20 @@ namespace App\Models;
 class Article extends BaseModel
 {
     protected $appends = ['is_collect'];
-
+    protected $table = 'articles';
+    public static $_post_type = [
+        1=>'没',
+        2=>'有',
+        3=>'分',
+        4=>'类'
+    ];
     public function getIsCollectAttribute()
     {
         if (!empty(request()->header('token'))) {
-            $user = User::getUserByToken();
-            if (Collection::where('user_id', $user['id'])->where('article_id', $this->id)->exists()) {
-                return 1;
-            }
+                $user = User::getUserByToken();
+                if (Collection::where('user_id', $user['id'])->where('article_id', $this->id)->exists()) {
+                    return 1;
+                }
         }
 
         return 0;

+ 15 - 0
app/Models/Banner.php

xqd
@@ -0,0 +1,15 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+
+class Banner extends Model
+{
+    //
+    protected $table = 'banner';
+    public static $_post_type = [
+        1=>'用户端',
+        2=>'医生端'
+    ];
+}

+ 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';
+}

+ 1 - 1
config/admin.php

xqd
@@ -95,7 +95,7 @@ return [
     | If your page is going to be accessed via https, set it to `true`.
     |
     */
-    'https' => env('ADMIN_HTTPS', true),
+    'https' => env('ADMIN_HTTPS', false),
 
     /*
     |--------------------------------------------------------------------------