DoctorManagementController.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. namespace App\Admin\Controllers\UserManagement\DocterManagement;
  3. use App\Admin\Actions\backstage\Docters\AddLabel;
  4. use App\Admin\Actions\backstage\Docters\DelLabel;
  5. use App\Admin\Actions\backstage\Docters\LabelManagement;
  6. use App\Admin\Actions\backstage\Docters\SignUp;
  7. use App\Admin\Actions\backstage\Docters\Team;
  8. use App\Models\Docter;
  9. use App\Models\DocterLabel;
  10. use App\Models\DocterOrganization;
  11. use App\Models\Organization;
  12. use App\Models\User;
  13. use Encore\Admin\Controllers\AdminController;
  14. use Encore\Admin\Form;
  15. use Encore\Admin\Grid;
  16. use Encore\Admin\Show;
  17. class DoctorManagementController extends AdminController
  18. {
  19. /**
  20. * Title for current resource.
  21. *
  22. * @var string
  23. */
  24. protected $title = '医生列表';
  25. /**
  26. * Make a grid builder.
  27. *
  28. * @return Grid
  29. */
  30. protected function grid()
  31. {
  32. $grid = new Grid(new Docter());
  33. $grid->disableCreateButton();
  34. $grid->filter(function ($filter){
  35. $filter->disableIdFilter();
  36. $filter->like('name','昵称');
  37. // $filter->like('organization','机构名称');
  38. $filter->where(function ($query) {
  39. $query->whereHas('organization',function ($query){
  40. $query->where('name','like',"%{$this->input}%");
  41. });
  42. },'机构名');
  43. $filter->equal('status','工作状态')->select([
  44. 0 => '禁用',
  45. 1 => '启用',
  46. ]);
  47. });
  48. $grid->actions(function ($actions) {
  49. // 去掉编辑
  50. $actions->disableEdit();
  51. // 去掉查看
  52. $actions->disableView();
  53. //签约管理
  54. $actions->add(new SignUp());
  55. //团队管理
  56. $actions->add(new Team());
  57. //标签管理
  58. $actions->add(new LabelManagement());
  59. });
  60. $grid->column('id', __('Id'))->sortable();
  61. $grid->column('name', __('姓名'));
  62. $grid->column('avatar', __('头像'))->lightbox(['width' =>'', 'height' => 30]);
  63. $grid->column('phone', __('电话'));
  64. $grid->column('score', __('评分'));
  65. $grid->column('service_persons', __('服务人数'));
  66. $states = [
  67. 'on' => ['value' => 1, 'text' => '启用', 'color' => 'primary'],
  68. 'off' => ['value' => 0, 'text' => '禁用', 'color' => 'danger'],
  69. ];
  70. $grid->column('status', __('工作状态'))->switch($states);
  71. $grid->column('organization', __('所属机构'))->pluck('name')->label('info');
  72. $grid->column('is_then', __('认证状态'))->using([0=>'未认证',1=>'已认证']);
  73. $grid->column('label', __('标签'))->display(function ($label){
  74. if($label==null)
  75. {
  76. return '无';
  77. }
  78. $label_value = DocterLabel::whereIn('id',$label)->where('status',1)->pluck('label_name');
  79. return $label_value;
  80. })->label('info');
  81. return $grid;
  82. }
  83. /**
  84. * Make a show builder.
  85. *
  86. * @param mixed $id
  87. * @return Show
  88. */
  89. protected function detail($id)
  90. {
  91. $show = new Show(Docter::findOrFail($id));
  92. return $show;
  93. }
  94. /**
  95. * Make a form builder.
  96. *
  97. * @return Form
  98. */
  99. protected function form()
  100. {
  101. $form = new Form(new Docter());
  102. $form->switch('status', __('状态'));
  103. return $form;
  104. }
  105. }