DoctorManagementController.php 4.9 KB

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