<?php

namespace App\Models;

use Core\Model;

class Admin extends Model
{
    protected $table = 'tb_user'; // sesuaikan dengan nama tabel

    /**
     * Cari dosen berdasarkan username
     */
    public function findByUsername($username)
    {
        $stmt = $this->query("SELECT * FROM {$this->table} WHERE username = ?", [$username]);
        return $stmt->fetch();
    }

    public function updateByUsername($username, $data)
    {
        $sql = "UPDATE {$this->table} SET 
            nama = ?
            WHERE username = ?";

        return $this->query($sql, [
            $data['nama'],
            $username
        ]);
    }

    /**
     * Ambil semua dosen
     */
    public function all()
    {
        return $this->query("SELECT * FROM {$this->table}")->fetchAll();
    }
}
