<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Http\Response\ResponseJson;
use App\Models\HealthLog;
use App\Models\User;
use Illuminate\Http\Request;

class HealthController extends Controller
{
    use ResponseJson;


    public function userHealthLogs(Request $request, User $user)
    {
        $logs = HealthLog::where('user_id', $user->id)->where('e_name', 'Weight')->select('user_id', 'e_name', 'score', 'tested_at')->paginate();
        return $this->success('ok', $logs);
    }

    public function userHealthLog(Request $request, User $user)
    {
        $tested_at = $request->input('tested_at');
        $logs = HealthLog::with('healthKind')->where('user_id', $user->id)->where('tested_at', $tested_at)->select('user_id', 'e_name', 'score', 'tested_at')->get();
        return $this->success('ok', $logs);
    }
}
