123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- <?php
- namespace App\Admin\Controllers\UserManagement\DocterManagement;
- use App\Admin\Actions\backstage\Docters\AddLabel;
- use App\Admin\Actions\backstage\Docters\DefaultOrganazation;
- use App\Admin\Actions\backstage\Docters\DelLabel;
- use App\Admin\Actions\backstage\Docters\LabelManagement;
- use App\Admin\Actions\backstage\Docters\ServiceManagement;
- use App\Admin\Actions\backstage\Docters\SignUp;
- use App\Admin\Actions\backstage\Docters\Team;
- use App\Models\Docter;
- use App\Models\DocterLabel;
- use App\Models\DocterOrganization;
- use App\Models\Organization;
- use App\Models\User;
- use Encore\Admin\Controllers\AdminController;
- use Encore\Admin\Form;
- use Encore\Admin\Grid;
- use Encore\Admin\Show;
- class DoctorManagementController extends AdminController
- {
- /**
- * Title for current resource.
- *
- * @var string
- */
- protected $title = '医生列表';
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- $grid = new Grid(new Docter());
- $grid->disableCreateButton();
- $grid->filter(function ($filter){
- $filter->disableIdFilter();
- $filter->like('name','姓名');
- $filter->equal('phone','电话');
- $filter->where(function ($query) {
- $query->whereHas('organization',function ($query){
- $query->where('intro','like',"%{$this->input}%");
- });
- },'所属机构');
- $filter->equal('status','工作状态')->select([
- 0 => '禁用',
- 1 => '启用',
- ]);
- $filter->equal('is_then','认证状态')->select([
- 0 => '未认证',
- 1 => '已认证',
- ]);
- });
- $grid->actions(function ($actions) {
- // 去掉编辑
- $actions->disableEdit();
- // 去掉查看
- $actions->disableView();
- $actions->disableDelete();
- //签约管理
- $actions->add(new SignUp());
- //团队管理
- $actions->add(new Team());
- //标签管理
- $actions->add(new LabelManagement());
- //服务管理
- $actions->add(new ServiceManagement());
- //修改默认医院
- $actions->add(new DefaultOrganazation());
- });
- $grid->model()->orderBy('id','desc');
- $grid->column('id', __('Id'))->sortable();
- $grid->column('name', __('姓名'));
- $grid->column('avatar', __('头像'))->lightbox(['width' =>'', 'height' => 30]);
- $grid->column('phone', __('电话'));
- $grid->column('score', __('评分'));
- $grid->column('service_persons', __('服务人数'));
- $grid->column('is_then', __('认证状态'))->using([0=>'未认证',1=>'已认证']);
- $states = [
- 'on' => ['value' => 1, 'text' => '启用', 'color' => 'primary'],
- 'off' => ['value' => 0, 'text' => '禁用', 'color' => 'danger'],
- ];
- $grid->column('org', __('所属机构'))->display(function (){
- $org_id = DocterOrganization::where('docter_id',$this->id)->where('state',1)->pluck('organization_id')->toArray();
- $name = Organization::whereIn('id',$org_id)->pluck('intro')->toArray();
- if (empty($name))
- {
- return '无';
- }
- else
- {
- return $name;
- }
- })->label('info')->width(300);
- $grid->column('serviceapply', __('开通服务'))->where('status',2)->pluck('service_type')->toArray()->display(function ($type){
- $type = array_unique($type);
- $type_arr = [];
- foreach ($type as $value)
- {
- if ($value == 1)
- {
- array_push($type_arr,'图文');
- }
- if ($value == 2)
- {
- array_push($type_arr,'电话');
- }
- if ($value == 3)
- {
- array_push($type_arr,'门诊');
- }
- }
- if($type_arr==null)
- {
- return '无';
- }
- return $type_arr;
- })->label('info');
- $grid->column('label', __('标签'))->display(function ($label){
- if($label==null)
- {
- return '无';
- }
- if($label == '无'){
- return '无';
- }
- $label_value = DocterLabel::whereIn('id',$label)->where('status',1)->pluck('label_name')->toArray();
- return $label_value;
- })->label('info');
- $grid->column('status', __('工作状态'))->switch($states);
- return $grid;
- }
- /**
- * Make a show builder.
- *
- * @param mixed $id
- * @return Show
- */
- protected function detail($id)
- {
- $show = new Show(Docter::findOrFail($id));
- return $show;
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form()
- {
- $form = new Form(new Docter());
- $form->switch('status', __('状态'));
- return $form;
- }
- }
|