ApproveController.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Admin\Actions\backstage\Pass;
  4. use App\Admin\Actions\backstage\Refuse;
  5. use App\Admin\Actions\backstage\Revoke;
  6. use App\Models\Docter;
  7. use App\Models\DocterOrganization;
  8. use App\Models\Office;
  9. use Encore\Admin\Controllers\AdminController;
  10. use Encore\Admin\Form;
  11. use Encore\Admin\Grid;
  12. use Encore\Admin\Show;
  13. class ApproveController extends AdminController
  14. {
  15. /**
  16. * Title for current resource.
  17. *
  18. * @var string
  19. */
  20. protected $title = '认证列表';
  21. /**
  22. * Make a grid builder.
  23. *
  24. * @return Grid
  25. */
  26. protected function grid()
  27. {
  28. $grid = new Grid(new DocterOrganization());
  29. $grid ->model()->where('state','>=','1');
  30. $grid->column('id', __('Id'));
  31. $grid->column('docter.id', __('医生ID'));
  32. $grid->column('docter.name', __('医生姓名'));
  33. $grid->column('docter.avatar', __('医生头像'))->image(50,50);
  34. $grid->column('docter.sex', __('性别'))->using([0=>'未知',1=>'男',2=>'女']);
  35. $grid->column('organization.name', __('机构'));
  36. $grid->column('office.name', __('科室'));
  37. $grid->column('qualification.name', __('医生资质'));
  38. $grid->column('state', __('认证状态'))->using([1=>'待审核',2=>'已认证',3=>'已驳回']);
  39. $grid->column('authentication_time', __('认证时间'));
  40. //禁用创建按钮
  41. $grid->disableCreateButton();
  42. $grid->actions(function ($actions) {
  43. // 去掉删除
  44. $actions->disableDelete();
  45. // 去掉编辑
  46. $actions->disableEdit();
  47. // 去掉查看
  48. $actions->disableView();
  49. //待审核状态下 给通过和驳回
  50. if ($actions->row->state == 1){
  51. //通过申请
  52. $actions->add(new Pass());
  53. //驳回申请
  54. $actions->add(new Refuse());
  55. }
  56. //已认证状态下 给撤销
  57. if ($actions->row->state == 2){
  58. $actions->add(new Revoke());
  59. }
  60. //驳回状态下 不给任何操作
  61. if ($actions->row->state == 3){
  62. }
  63. });
  64. return $grid;
  65. }
  66. /**
  67. * Make a show builder.
  68. *
  69. * @param mixed $id
  70. * @return Show
  71. */
  72. protected function detail($id)
  73. {
  74. $show = new Show(DocterOrganization::findOrFail($id));
  75. $show->field('id', __('Id'));
  76. $show->field('docter.id', __('医生ID'));
  77. $show->field('docter.name', __('名字'));
  78. $show->field('docter.sex', __('性别'))->using([0=>'未知',1=>'男',2=>'女']);
  79. $show->field('docter.card_id', __('身份证'));
  80. $show->field('organization.name', __('机构'));
  81. $show->field('office.name', __('科室'));
  82. $show->field('qualification.name', __('医生资质'));
  83. // $show->field('docter.card_photo', __('身份证正反面'))->as(function ($id){
  84. //// dd($id);
  85. // $imgs = explode(',',$id);
  86. // $html = '';
  87. // foreach ($imgs as $val){
  88. // $html .='img src="'.$val.'"';
  89. // }
  90. // return "<{$html}>";
  91. //// return json_decode($id,true);
  92. // });
  93. $show->field('docter.card_photo', __('身份证正反面'))->image();
  94. return $show;
  95. }
  96. /**
  97. * Make a form builder.
  98. *
  99. * @return Form
  100. */
  101. protected function form()
  102. {
  103. $form = new Form(new DocterOrganization());
  104. $form->number('docter_id', __('Docter id'));
  105. $form->number('organization_id', __('Organization id'));
  106. $form->number('offices_id', __('Offices id'));
  107. $form->number('qualifications_id', __('Qualifications id'));
  108. $form->number('state', __('State'));
  109. return $form;
  110. }
  111. }