DoctorManagementController.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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->equal('status','工作状态')->select([
  38. 0 => '禁用',
  39. 1 => '启用',
  40. ]);
  41. });
  42. $grid->actions(function ($actions) {
  43. // 去掉编辑
  44. $actions->disableEdit();
  45. // 去掉查看
  46. $actions->disableView();
  47. //签约管理
  48. $actions->add(new SignUp());
  49. //团队管理
  50. $actions->add(new Team());
  51. //标签管理
  52. $actions->add(new LabelManagement());
  53. });
  54. $grid->column('id', __('Id'))->sortable();
  55. $grid->column('name', __('姓名'));
  56. $grid->column('avatar', __('头像'))->image('',50,50);
  57. $grid->column('score', __('评分'));
  58. $grid->column('service_persons', __('服务人数'));
  59. $states = [
  60. 'on' => ['value' => 1, 'text' => '启用', 'color' => 'primary'],
  61. 'off' => ['value' => 0, 'text' => '禁用', 'color' => 'danger'],
  62. ];
  63. $grid->column('status', __('工作状态'))->switch($states);
  64. $grid->column('is_then', __('认证状态'))->using([0=>'未认证',1=>'已认证']);
  65. $grid->column('label', __('标签'))->display(function ($label){
  66. $label_value = DocterLabel::whereIn('id',$label)->pluck('label_name');
  67. return $label_value;
  68. })->label('info');
  69. return $grid;
  70. }
  71. /**
  72. * Make a show builder.
  73. *
  74. * @param mixed $id
  75. * @return Show
  76. */
  77. protected function detail($id)
  78. {
  79. $show = new Show(Docter::findOrFail($id));
  80. return $show;
  81. }
  82. /**
  83. * Make a form builder.
  84. *
  85. * @return Form
  86. */
  87. protected function form()
  88. {
  89. $form = new Form(new Docter());
  90. $form->switch('status', __('状态'));
  91. return $form;
  92. }
  93. }