CheckInController.php 2.7 KB

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