ApproveController.php 3.8 KB

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