<?php

declare(strict_types=1);

namespace BotGuard\Models;

use BotGuard\Core\Model;

/**
 * Platform account (admin or dashboard user).
 */
final class User extends Model
{
    protected string $table = 'users';

    public function findByEmail(string $email): ?array
    {
        return $this->firstWhere(['email' => strtolower(trim($email))]);
    }

    public function touchLogin(int $id): void
    {
        $this->updateById($id, ['last_login_at' => now()]);
    }
}
