DoctorManagementController.php 5.1 KB

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