<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class User_model extends CI_Model {

    public function register($data) {
        return $this->db->insert('users', $data);
    }

    public function login_by_nik($nik, $password) {
        $user = $this->db->get_where('users', ['nik' => $nik])->row();
        if ($user && password_verify($password, $user->password)) {
            return $user;
        }
        return false;
    }

    public function login_by_email($email, $password) {
        $user = $this->db->get_where('users', ['email' => $email])->row();
        if ($user && password_verify($password, $user->password)) {
            return $user;
        }
        return false;
    }
}