DoctorManagementController.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <?php
  2. namespace App\Admin\Controllers\UserManagement\DocterManagement;
  3. use App\Admin\Actions\backstage\Docters\AddLabel;
  4. use App\Admin\Actions\backstage\Docters\DefaultOrganazation;
  5. use App\Admin\Actions\backstage\Docters\DelLabel;
  6. use App\Admin\Actions\backstage\Docters\LabelManagement;
  7. use App\Admin\Actions\backstage\Docters\ServiceManagement;
  8. use App\Admin\Actions\backstage\Docters\SignUp;
  9. use App\Admin\Actions\backstage\Docters\Team;
  10. use App\Models\Docter;
  11. use App\Models\DocterLabel;
  12. use App\Models\DocterOrganization;
  13. use App\Models\Organization;
  14. use App\Models\User;
  15. use Encore\Admin\Controllers\AdminController;
  16. use Encore\Admin\Form;
  17. use Encore\Admin\Grid;
  18. use Encore\Admin\Show;
  19. class DoctorManagementController extends AdminController
  20. {
  21. /**
  22. * Title for current resource.
  23. *
  24. * @var string
  25. */
  26. protected $title = '医生列表';
  27. /**
  28. * Make a grid builder.
  29. *
  30. * @return Grid
  31. */
  32. protected function grid()
  33. {
  34. $grid = new Grid(new Docter());
  35. $grid->disableCreateButton();
  36. $grid->filter(function ($filter){
  37. $filter->disableIdFilter();
  38. $filter->like('name','姓名');
  39. $filter->equal('phone','电话');
  40. $filter->where(function ($query) {
  41. $query->whereHas('organization',function ($query){
  42. $query->where('intro','like',"%{$this->input}%");
  43. });
  44. },'所属机构');
  45. $filter->equal('status','工作状态')->select([
  46. 0 => '禁用',
  47. 1 => '启用',
  48. ]);
  49. $filter->equal('is_then','认证状态')->select([
  50. 0 => '未认证',
  51. 1 => '已认证',
  52. ]);
  53. });
  54. $grid->disableBatchActions();
  55. $grid->actions(function ($actions) {
  56. // 去掉编辑
  57. $actions->disableEdit();
  58. // 去掉查看
  59. $actions->disableView();
  60. $actions->disableDelete();
  61. //签约管理
  62. $actions->add(new SignUp());
  63. //团队管理
  64. $actions->add(new Team());
  65. //标签管理
  66. $actions->add(new LabelManagement());
  67. //服务管理
  68. $actions->add(new ServiceManagement());
  69. //修改默认医院
  70. $actions->add(new DefaultOrganazation());
  71. });
  72. $grid->model()->orderBy('id','desc');
  73. $grid->column('id', __('Id'))->sortable();
  74. $grid->column('name', __('姓名'));
  75. $grid->column('avatar', __('头像'))->lightbox(['width' =>'', 'height' => 30]);
  76. $grid->column('phone', __('电话'));
  77. $grid->column('score', __('评分'));
  78. $grid->column('service_persons', __('服务人数'));
  79. $grid->column('is_then', __('认证状态'))->using([0=>'未认证',1=>'已认证']);
  80. $states = [
  81. 'on' => ['value' => 1, 'text' => '启用', 'color' => 'primary'],
  82. 'off' => ['value' => 0, 'text' => '禁用', 'color' => 'danger'],
  83. ];
  84. $grid->column('org', __('所属机构'))->display(function (){
  85. $org_id = DocterOrganization::where('docter_id',$this->id)->where('state',1)->pluck('organization_id')->toArray();
  86. $name = Organization::whereIn('id',$org_id)->pluck('intro')->toArray();
  87. if (empty($name))
  88. {
  89. return '无';
  90. }
  91. else
  92. {
  93. return $name;
  94. }
  95. })->label('info')->width(300);
  96. $grid->column('serviceapply', __('开通服务'))->where('status',2)->pluck('service_type')->toArray()->display(function ($type){
  97. $type = array_unique($type);
  98. $type_arr = [];
  99. foreach ($type as $value)
  100. {
  101. if ($value == 1)
  102. {
  103. array_push($type_arr,'图文');
  104. }
  105. if ($value == 2)
  106. {
  107. array_push($type_arr,'电话');
  108. }
  109. if ($value == 3)
  110. {
  111. array_push($type_arr,'门诊');
  112. }
  113. }
  114. if($type_arr==null)
  115. {
  116. return '无';
  117. }
  118. return $type_arr;
  119. })->label('info');
  120. $grid->column('label', __('标签'))->display(function ($label){
  121. if($label==null)
  122. {
  123. return '无';
  124. }
  125. if($label == '无'){
  126. return '无';
  127. }
  128. $label_value = DocterLabel::whereIn('id',$label)->where('status',1)->pluck('label_name')->toArray();
  129. return $label_value;
  130. })->label('info');
  131. $grid->column('status', __('工作状态'))->switch($states);
  132. return $grid;
  133. }
  134. /**
  135. * Make a show builder.
  136. *
  137. * @param mixed $id
  138. * @return Show
  139. */
  140. protected function detail($id)
  141. {
  142. $show = new Show(Docter::findOrFail($id));
  143. return $show;
  144. }
  145. /**
  146. * Make a form builder.
  147. *
  148. * @return Form
  149. */
  150. protected function form()
  151. {
  152. $form = new Form(new Docter());
  153. $form->switch('status', __('状态'));
  154. return $form;
  155. }
  156. }