<?php

namespace App\Models;

use CodeIgniter\Model;

class UserModel extends Model
{
    protected $table         = 'users';
    protected $primaryKey    = 'id';
    protected $returnType    = 'array';
    protected $useTimestamps = true;
    protected $allowedFields = [
        'name',
        'email',
        'password_hash',
        'role',
        'status',
        'last_login_at',
    ];

    public function findActiveByEmail(string $email): ?array
    {
        return $this->where('email', $email)->where('status', 'active')->first();
    }

    public function findByEmail(string $email): ?array
    {
        return $this->where('email', $email)->first();
    }
}
