DoctorManagementController.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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->actions(function ($actions) {
  55. // 去掉编辑
  56. $actions->disableEdit();
  57. // 去掉查看
  58. $actions->disableView();
  59. $actions->disableDelete();
  60. //签约管理
  61. $actions->add(new SignUp());
  62. //团队管理
  63. $actions->add(new Team());
  64. //标签管理
  65. $actions->add(new LabelManagement());
  66. //服务管理
  67. $actions->add(new ServiceManagement());
  68. //修改默认医院
  69. $actions->add(new DefaultOrganazation());
  70. });
  71. $grid->model()->orderBy('id','desc');
  72. $grid->column('id', __('Id'))->sortable();
  73. $grid->column('name', __('姓名'));
  74. $grid->column('avatar', __('头像'))->lightbox(['width' =>'', 'height' => 30]);
  75. $grid->column('phone', __('电话'));
  76. $grid->column('score', __('评分'));
  77. $grid->column('service_persons', __('服务人数'));
  78. $grid->column('is_then', __('认证状态'))->using([0=>'未认证',1=>'已认证']);
  79. $states = [
  80. 'on' => ['value' => 1, 'text' => '启用', 'color' => 'primary'],
  81. 'off' => ['value' => 0, 'text' => '禁用', 'color' => 'danger'],
  82. ];
  83. $grid->column('org', __('所属机构'))->display(function (){
  84. $org_id = DocterOrganization::where('docter_id',$this->id)->where('state',1)->pluck('organization_id')->toArray();
  85. $name = Organization::whereIn('id',$org_id)->pluck('intro')->toArray();
  86. if (empty($name))
  87. {
  88. return '无';
  89. }
  90. else
  91. {
  92. return $name;
  93. }
  94. })->label('info')->width(300);
  95. $grid->column('serviceapply', __('开通服务'))->where('status',2)->pluck('service_type')->toArray()->display(function ($type){
  96. $type = array_unique($type);
  97. $type_arr = [];
  98. foreach ($type as $value)
  99. {
  100. if ($value == 1)
  101. {
  102. array_push($type_arr,'图文');
  103. }
  104. if ($value == 2)
  105. {
  106. array_push($type_arr,'电话');
  107. }
  108. if ($value == 3)
  109. {
  110. array_push($type_arr,'门诊');
  111. }
  112. }
  113. if($type_arr==null)
  114. {
  115. return '无';
  116. }
  117. return $type_arr;
  118. })->label('info');
  119. $grid->column('label', __('标签'))->display(function ($label){
  120. if($label==null)
  121. {
  122. return '无';
  123. }
  124. if($label == '无'){
  125. return '无';
  126. }
  127. $label_value = DocterLabel::whereIn('id',$label)->where('status',1)->pluck('label_name')->toArray();
  128. return $label_value;
  129. })->label('info');
  130. $grid->column('status', __('工作状态'))->switch($states);
  131. return $grid;
  132. }
  133. /**
  134. * Make a show builder.
  135. *
  136. * @param mixed $id
  137. * @return Show
  138. */
  139. protected function detail($id)
  140. {
  141. $show = new Show(Docter::findOrFail($id));
  142. return $show;
  143. }
  144. /**
  145. * Make a form builder.
  146. *
  147. * @return Form
  148. */
  149. protected function form()
  150. {
  151. $form = new Form(new Docter());
  152. $form->switch('status', __('状态'));
  153. return $form;
  154. }
  155. }