DocterChatController.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. namespace App\Community\Controllers;
  3. use App\Admin\Actions\Community\Docter\Chat;
  4. use App\Admin\Actions\Community\Notice\sendNotice;
  5. use App\Admin\Actions\Community\Order\Detail;
  6. use App\Models\Docter;
  7. use App\Models\Order;
  8. use Encore\Admin\Controllers\AdminController;
  9. use Encore\Admin\Facades\Admin;
  10. use Encore\Admin\Form;
  11. use Encore\Admin\Grid;
  12. use Encore\Admin\Layout\Content;
  13. use Encore\Admin\Show;
  14. use App\Models\User;
  15. class DocterChatController extends AdminController
  16. {
  17. /**
  18. * Title for current resource.
  19. *
  20. * @var string
  21. */
  22. protected $title = '咨询订单';
  23. /**
  24. * Make a grid builder.
  25. *
  26. * @return Grid
  27. */
  28. protected function grid()
  29. {
  30. $grid = new Grid(new Order());
  31. $user = Admin::user();
  32. $org_id = $user->org_id;
  33. $docter_id = $user->docter_id;
  34. $is_admin = Admin::user()->inRoles(['administrator','devloper']);
  35. $grid->batchActions(function ($batch) {
  36. $batch->add(new sendNotice());
  37. });
  38. if(!$is_admin){
  39. $where['organization_id']=$org_id;
  40. if($docter_id){
  41. $where['docter_id'] = $docter_id;
  42. }
  43. $grid->model()->where($where);
  44. // $grid->model()->whereHas('orders',function ($query) use ($org_id,$docter_id) {
  45. // $query->where($where);
  46. // });
  47. }
  48. $grid->column('order_sn', __('订单号'));
  49. $grid->column('orderUser.nickname', __('咨询用户'));
  50. $grid->column('orderPatient.name', __('咨询患者'));
  51. $grid->column('orderPatient.birthday', __('患者年龄'))->display(function ($w){
  52. return birthday_to_age($w);
  53. });
  54. $grid->actions(function ($actions) use($docter_id) {
  55. if($docter_id){
  56. $actions->add( new Chat());
  57. }
  58. $actions->add(new Detail());
  59. $actions->disableDelete();
  60. $actions->disableView();
  61. $actions->disableEdit();
  62. });
  63. $grid->filter(function ($filter){
  64. $filter->disableIdFilter();
  65. $filter->equal('order_status','订单状态')->select(Order::$_order_status);
  66. });
  67. $grid->column('order_status', __('订单状态'))->using(Order::$_order_status);
  68. $grid->column('created_at', __('下单时间'));
  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. return '';
  80. }
  81. /**
  82. * Make a form builder.
  83. *
  84. * @return Form
  85. */
  86. protected function form()
  87. {
  88. return '';
  89. }
  90. function chats(Content $content){
  91. $content->title('咨询订单 ');
  92. $content->description('医生用户可以接受预约');
  93. $user = Admin::user();
  94. $org_id = $user->org_id;
  95. $docter_id = $user->docter_id;
  96. $url = '/cdms/chat_view?docter_id='.$docter_id;
  97. // $content->body('<iframe src="/cdms/chat_view?docter_id='.$docter_id.'" style="width: 100%;height:800px;border: none"></iframe>');
  98. $content->body('<iframe src="/cdms/chat_view?docter_id='.$docter_id.'" style="width: 100%;height:800px;border: none"></iframe>');
  99. return $content;
  100. }
  101. public function chat_view()
  102. {
  103. return view('cdms.chat');
  104. }
  105. }