<?php

namespace App\Models;

use App\Core\Model;

class AdminUserModel extends Model
{
    protected string $table = 'admin_users';

    public function findByUsername(string $username): array|false
    {
        $stmt = $this->db->prepare("SELECT * FROM {$this->table} WHERE username = :username LIMIT 1");
        $stmt->execute(['username' => $username]);

        return $stmt->fetch();
    }

    public function updateLastLogin(int $id): void
    {
        $stmt = $this->db->prepare("UPDATE {$this->table} SET last_login = NOW() WHERE id = :id");
        $stmt->execute(['id' => $id]);
    }
}
