PutdataController.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace App\Admin\Controllers\UserManagement\DocterManagement;
  3. use App\Models\Docter;
  4. use App\Models\Serviceapplys;
  5. use Encore\Admin\Controllers\AdminController;
  6. use Encore\Admin\Form;
  7. use Encore\Admin\Grid;
  8. use Encore\Admin\Show;
  9. class PutdataController extends AdminController
  10. {
  11. public function putdata(){
  12. $id = \request('id');
  13. $in_chat = \request('in_chat');
  14. $chat_num = 0;
  15. $in_phone = \request('in_phone');
  16. $phone_num = 0;
  17. $in_appoint = \request('in_appoint');
  18. $appoint_num = 0;
  19. //判断图文
  20. if ($in_chat == 'on')
  21. {
  22. $chat_num = 2;
  23. }else{
  24. $chat_num = 3;
  25. }
  26. //判断电话
  27. if ($in_phone == 'on')
  28. {
  29. $phone_num = 2;
  30. }else{
  31. $phone_num = 3;
  32. }
  33. //判断预约
  34. if ($in_appoint == 'on')
  35. {
  36. $appoint_num = 2;
  37. }else{
  38. $appoint_num = 3;
  39. }
  40. $info = Serviceapplys::where('docter_id',$id)->get()->toArray();
  41. // dd($info);
  42. foreach ($info as $k)
  43. {
  44. //图文的更改
  45. if ($k['service_type'] == 1)
  46. {
  47. $a = Serviceapplys::where('docter_id',$id)->where('service_type',1)->update(['status'=> $chat_num]);
  48. if ($chat_num == 3)
  49. {
  50. Docter::where('id',$id)->update(['is_chat'=>0]);
  51. }
  52. }
  53. //电话的更改
  54. if ($k['service_type'] == 2)
  55. {
  56. Serviceapplys::where('docter_id',$id)->where('service_type',2)->update(['status'=> $phone_num]);
  57. if ($phone_num == 3)
  58. {
  59. Docter::where('id',$id)->update(['is_phone'=>0]);
  60. }
  61. }
  62. //预约的更改
  63. if ($k['service_type'] == 3)
  64. {
  65. Serviceapplys::where('docter_id',$id)->where('service_type',3)->update(['status'=> $appoint_num]);
  66. if ($appoint_num == 3)
  67. {
  68. Docter::where('id',$id)->update(['is_appoint'=>0]);
  69. }
  70. }
  71. }
  72. return redirect('/admin/docters_service?id='.$id.'');
  73. }
  74. }