DoctorManagementController.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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->model()->orderBy('id','desc');
  61. $grid->column('id', __('Id'))->sortable();
  62. $grid->column('name', __('姓名'));
  63. $grid->column('avatar', __('头像'))->lightbox(['width' =>'', 'height' => 30]);
  64. $grid->column('phone', __('电话'));
  65. $grid->column('score', __('评分'));
  66. $grid->column('service_persons', __('服务人数'));
  67. $states = [
  68. 'on' => ['value' => 1, 'text' => '启用', 'color' => 'primary'],
  69. 'off' => ['value' => 0, 'text' => '禁用', 'color' => 'danger'],
  70. ];
  71. $grid->column('status', __('工作状态'))->switch($states);
  72. $grid->column('organization', __('所属机构'))->pluck('name')->label('info');
  73. $grid->column('is_then', __('认证状态'))->using([0=>'未认证',1=>'已认证']);
  74. $grid->column('label', __('标签'))->display(function ($label){
  75. if($label==null)
  76. {
  77. return '无';
  78. }
  79. $label_value = DocterLabel::whereIn('id',$label)->where('status',1)->pluck('label_name');
  80. return $label_value;
  81. })->label('info');
  82. return $grid;
  83. }
  84. /**
  85. * Make a show builder.
  86. *
  87. * @param mixed $id
  88. * @return Show
  89. */
  90. protected function detail($id)
  91. {
  92. $show = new Show(Docter::findOrFail($id));
  93. return $show;
  94. }
  95. /**
  96. * Make a form builder.
  97. *
  98. * @return Form
  99. */
  100. protected function form()
  101. {
  102. $form = new Form(new Docter());
  103. $form->switch('status', __('状态'));
  104. return $form;
  105. }
  106. }