activityId)->get(); } public function draw_user_when_check_in(StoreCheckInRequest $request) { return CheckIn::where('is_checked_in', 'true')->get()->random($request->number); } public function draw_user_by_region(StoreCheckInRequest $request) { return CheckIn::where('is_checked_in', 'true') ->whereTime('check_ins.updated_at', '<=', $request->deadline) ->whereIn('region', $request->region) ->get() ->random($request->number); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { // } /** * Store a newly created resource in storage. * * @param \App\Http\Requests\StoreCheckInRequest $request * @return \Illuminate\Http\Response */ public function store(StoreCheckInRequest $request) { // } /** * Display the specified resource. * * @param \App\Models\CheckIn $checkIn * @return \Illuminate\Http\Response */ public function show(Request $request, CheckIn $checkIn) { // $checkIn = CheckIn::where('user_id', '=', $request->id)->where('activity_id', '=', $request->activity_id)->first(); $department = Department::where('department_id', '=', $checkIn->department_id)->first(); $checkIn->department = $department->department_name; $response = [ 'checkIn' => $checkIn, ]; return response($response, 201); } /** * Show the form for editing the specified resource. * * @param \App\Models\CheckIn $checkIn * @return \Illuminate\Http\Response */ public function edit(CheckIn $checkIn) { // } /** * Update the specified resource in storage. * * @param \App\Http\Requests\UpdateCheckInRequest $request * @param \App\Models\CheckIn $checkIn * @return \Illuminate\Http\Response */ public function update(UpdateCheckInRequest $request, CheckIn $checkIn) { CheckIn::where('user_id', $request->user_id)->update(['is_checked_in' => true]); return 'success'; } public function check_out(UpdateCheckInRequest $request, CheckIn $checkIn) { CheckIn::where('user_id', $request->user_id)->update(['is_checked_in' => false]); return 'success'; } /** * Remove the specified resource from storage. * * @param \App\Models\CheckIn $checkIn * @return \Illuminate\Http\Response */ public function destroy(CheckIn $checkIn) { // } }