<?php

namespace App\Http\Controllers\API;

use App\Http\Controllers\Controller;
use App\Models\User;
use App\Traits\GetHumanIDTrait;
use Illuminate\Http\Request;

class SearchIDdocument extends Controller
{
    use GetHumanIDTrait;

    /**
     * Display a listing of the resource.
     */
    public function index()
    {
        //
    }


    /**
     * Display the specified resource.
     */
    public function show(string $id)
    {
        //
    }

    protected function id_check($id, $serial, Request $request)
    {
        //$token = $request->query('apikey');
        //if (!$token || !User::where('token', $token)->exists()) {
          //  return response()->json(['error' => 'Unauthorized'], 401);
        //}else {
            //query
            if (!empty($id)) {
                $human = $this->apiGetHuman($id);
                return response()->json([
                    'status' => 'success',
                    'id' => $id,
                    'serial' => $serial,
                    'human' => $human
                ], 200);
            }

            return response()->json([
                'status' => 'Not Found',
                'data' => [
                    'id' => $id,
                    'serial' => $serial
                ]
            ], 400);
        }
    //}
}
