ApproveController.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <?php
  2. namespace App\Admin\Controllers\UserManagement\DocterManagement;
  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->filter(function($filter){
  30. $filter->disableIdFilter();
  31. $filter->like('docter.name','医生姓名');
  32. $filter->like('organization.name','机构名');
  33. $filter->between('authentication_time', '签约时间')->datetime();
  34. $filter->between('authentication_end_time', '签约到期时间')->datetime();
  35. });
  36. $grid ->model()->where('state','>',0)->orderBy('id','desc');
  37. $grid->column('id', __('Id'));
  38. $grid->column('docter.id', __('医生ID'));
  39. $grid->column('docter.name', __('医生姓名'));
  40. $grid->column('docter.phone', __('医生电话'));
  41. $grid->column('docter.avatar', __('医生头像'))->lightbox(['width' =>'', 'height' => 30]);
  42. $grid->column('docter.sex', __('性别'))->using([0=>'未知',1=>'男',2=>'女']);
  43. $grid->column('organization.name', __('机构'));
  44. $grid->column('office.name', __('科室'));
  45. $grid->column('qualification.name', __('医生资质'));
  46. $grid->column('remarks', __('备注'));
  47. $grid->column('docter.practice','医生照片和执业证书')->display(function ($img) {
  48. $arr = explode(',',$img);
  49. $new_arr = [];
  50. foreach ($arr as $value)
  51. {
  52. $value = str_replace('upload/','',$value);
  53. array_push($new_arr,$value);
  54. }
  55. return $new_arr;
  56. })->lightbox(['width' =>'', 'height' => 30]);
  57. $grid->column('docter.card_photo',' 身份证正反面')->display(function ($img) {
  58. $arr = explode(',',$img);
  59. $new_arr = [];
  60. foreach ($arr as $value)
  61. {
  62. $value = str_replace('upload/','',$value);
  63. array_push($new_arr,$value);
  64. }
  65. return $new_arr;
  66. })->lightbox(['width' =>'', 'height' => 30]);
  67. $grid->column('docter.is_quail','照片和资格证书')->display(function ($img) {
  68. $arr = explode(',',$img);
  69. $new_arr = [];
  70. foreach ($arr as $value)
  71. {
  72. $value = str_replace('upload/','',$value);
  73. array_push($new_arr,$value);
  74. }
  75. return $new_arr;
  76. })->lightbox(['width' =>'', 'height' => 30]);
  77. $grid->column('state', __('认证状态'))->using([1=>'已认证',2=>'审核驳回',3=>'待审核'])->label('info');
  78. $grid->column('authentication_time', __('签约时间'))->display(function ($time){
  79. if ($time == 0){
  80. return '';
  81. }else
  82. {
  83. return $time;
  84. }
  85. });
  86. $grid->column('authentication_end_time', __('签约到期时间'))->display(function ($time){
  87. if ($time == 0){
  88. return '';
  89. }else
  90. {
  91. return $time;
  92. }
  93. });
  94. //禁用创建按钮
  95. $grid->disableCreateButton();
  96. $grid->actions(function ($actions) {
  97. // 去掉删除
  98. $actions->disableDelete();
  99. // 去掉编辑
  100. $actions->disableEdit();
  101. // 去掉查看
  102. $actions->disableView();
  103. //待审核状态下 给通过和驳回
  104. if ($actions->row->state == 3){
  105. //通过申请
  106. $actions->add(new Pass());
  107. //驳回申请
  108. $actions->add(new Refuse());
  109. }
  110. //已认证状态下 给撤销
  111. if ($actions->row->state == 1){
  112. $actions->add(new Revoke());
  113. }
  114. //驳回状态下 不给任何操作
  115. if ($actions->row->state == 2){
  116. }
  117. });
  118. return $grid;
  119. }
  120. /**
  121. * Make a show builder.
  122. *
  123. * @param mixed $id
  124. * @return Show
  125. */
  126. protected function detail($id)
  127. {
  128. $show = new Show(DocterOrganization::findOrFail($id));
  129. $show->field('id', __('Id'));
  130. $show->field('docter.id', __('医生ID'));
  131. $show->field('docter.name', __('名字'));
  132. $show->field('docter.sex', __('性别'))->using([0=>'未知',1=>'男',2=>'女']);
  133. $show->field('docter.card_id', __('身份证'));
  134. $show->field('organization.name', __('机构'));
  135. $show->field('office.name', __('科室'));
  136. $show->field('qualification.name', __('医生资质'));
  137. // $show->field('docter.card_photo', __('身份证正反面'))->as(function ($id){
  138. //// dd($id);
  139. // $imgs = explode(',',$id);
  140. // $html = '';
  141. // foreach ($imgs as $val){
  142. // $html .='img src="'.$val.'"';
  143. // }
  144. // return "<{$html}>";
  145. //// return json_decode($id,true);
  146. // });
  147. $show->field('docter.card_photo', __('身份证正反面'))->image();
  148. return $show;
  149. }
  150. /**
  151. * Make a form builder.
  152. *
  153. * @return Form
  154. */
  155. protected function form()
  156. {
  157. $form = new Form(new DocterOrganization());
  158. $form->number('docter_id', __('Docter id'));
  159. $form->number('organization_id', __('Organization id'));
  160. $form->number('offices_id', __('Offices id'));
  161. $form->number('qualifications_id', __('Qualifications id'));
  162. $form->number('state', __('State'));
  163. return $form;
  164. }
  165. }