CheckInController.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Models\CheckIn;
  4. use App\Models\User;
  5. use App\Http\Requests\StoreCheckInRequest;
  6. use App\Http\Requests\UpdateCheckInRequest;
  7. class CheckInController extends Controller
  8. {
  9. /**
  10. * Display a listing of the resource.
  11. *
  12. * @return \Illuminate\Http\Response
  13. */
  14. public function index()
  15. {
  16. //
  17. }
  18. public function draw_user_when_check_in(StoreCheckInRequest $request)
  19. {
  20. return CheckIn::where('is_checked_in', 'true')->get()->random($request->number);
  21. }
  22. public function draw_user_with_place(StoreCheckInRequest $request)
  23. {
  24. return CheckIn::where('is_checked_in', 'true')
  25. ->whereTime('check_ins.updated_at', '<=', '2023-02-08 08:23:42')
  26. ->whereIn('region', $request->region)
  27. ->get()
  28. ->random($request->number);
  29. }
  30. /**
  31. * Show the form for creating a new resource.
  32. *
  33. * @return \Illuminate\Http\Response
  34. */
  35. public function create()
  36. {
  37. //
  38. }
  39. /**
  40. * Store a newly created resource in storage.
  41. *
  42. * @param \App\Http\Requests\StoreCheckInRequest $request
  43. * @return \Illuminate\Http\Response
  44. */
  45. public function store(StoreCheckInRequest $request)
  46. {
  47. //
  48. }
  49. /**
  50. * Display the specified resource.
  51. *
  52. * @param \App\Models\CheckIn $checkIn
  53. * @return \Illuminate\Http\Response
  54. */
  55. public function show(CheckIn $checkIn)
  56. {
  57. //
  58. }
  59. /**
  60. * Show the form for editing the specified resource.
  61. *
  62. * @param \App\Models\CheckIn $checkIn
  63. * @return \Illuminate\Http\Response
  64. */
  65. public function edit(CheckIn $checkIn)
  66. {
  67. //
  68. }
  69. /**
  70. * Update the specified resource in storage.
  71. *
  72. * @param \App\Http\Requests\UpdateCheckInRequest $request
  73. * @param \App\Models\CheckIn $checkIn
  74. * @return \Illuminate\Http\Response
  75. */
  76. public function update(UpdateCheckInRequest $request, CheckIn $checkIn)
  77. {
  78. CheckIn::where('user_id', $request->userId)->update(['is_check_in' => true]);
  79. return 'success';
  80. }
  81. public function check_out(UpdateCheckInRequest $request, CheckIn $checkIn)
  82. {
  83. CheckIn::where('user_id', $request->userId)->update(['is_check_in' => false]);
  84. return 'success';
  85. }
  86. /**
  87. * Remove the specified resource from storage.
  88. *
  89. * @param \App\Models\CheckIn $checkIn
  90. * @return \Illuminate\Http\Response
  91. */
  92. public function destroy(CheckIn $checkIn)
  93. {
  94. //
  95. }
  96. }