<?php

namespace App\Modules\Integrations\Platform\Repositories;

use App\Modules\Integrations\Platform\Models\ApiToken;
use Illuminate\Support\Carbon;

final class ApiTokenRepository
{
    public function findByHash(string $tokenHash): ?ApiToken
    {
        return ApiToken::query()->where('token_hash', $tokenHash)->first();
    }

    public function touchLastUsed(ApiToken $token, Carbon $at): void
    {
        $token->forceFill(['last_used_at' => $at])->save();
    }
}

