ApproveController.php 6.1 KB

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