CheckInController.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 index_by_activity(UpdateCheckInRequest $request)
  19. {
  20. return CheckIn::where('activity_id', $request->activityId)->get();
  21. }
  22. public function draw_user_when_check_in(StoreCheckInRequest $request)
  23. {
  24. return CheckIn::where('is_checked_in', 'true')->get()->random($request->number);
  25. }
  26. public function draw_user_by_region(StoreCheckInRequest $request)
  27. {
  28. return CheckIn::where('is_checked_in', 'true')
  29. ->whereTime('check_ins.updated_at', '<=', $request->deadline)
  30. ->whereIn('region', $request->region)
  31. ->get()
  32. ->random($request->number);
  33. }
  34. /**
  35. * Show the form for creating a new resource.
  36. *
  37. * @return \Illuminate\Http\Response
  38. */
  39. public function create()
  40. {
  41. //
  42. }
  43. /**
  44. * Store a newly created resource in storage.
  45. *
  46. * @param \App\Http\Requests\StoreCheckInRequest $request
  47. * @return \Illuminate\Http\Response
  48. */
  49. public function store(StoreCheckInRequest $request)
  50. {
  51. //
  52. }
  53. /**
  54. * Display the specified resource.
  55. *
  56. * @param \App\Models\CheckIn $checkIn
  57. * @return \Illuminate\Http\Response
  58. */
  59. public function show(CheckIn $checkIn)
  60. {
  61. //
  62. }
  63. /**
  64. * Show the form for editing the specified resource.
  65. *
  66. * @param \App\Models\CheckIn $checkIn
  67. * @return \Illuminate\Http\Response
  68. */
  69. public function edit(CheckIn $checkIn)
  70. {
  71. //
  72. }
  73. /**
  74. * Update the specified resource in storage.
  75. *
  76. * @param \App\Http\Requests\UpdateCheckInRequest $request
  77. * @param \App\Models\CheckIn $checkIn
  78. * @return \Illuminate\Http\Response
  79. */
  80. public function update(UpdateCheckInRequest $request, CheckIn $checkIn)
  81. {
  82. CheckIn::where('user_id', $request->user_id)->update(['is_checked_in' => true]);
  83. return 'success';
  84. }
  85. public function check_out(UpdateCheckInRequest $request, CheckIn $checkIn)
  86. {
  87. CheckIn::where('user_id', $request->user_id)->update(['is_checked_in' => false]);
  88. return 'success';
  89. }
  90. /**
  91. * Remove the specified resource from storage.
  92. *
  93. * @param \App\Models\CheckIn $checkIn
  94. * @return \Illuminate\Http\Response
  95. */
  96. public function destroy(CheckIn $checkIn)
  97. {
  98. //
  99. }
  100. }