<?php
namespace App\Models;
use CodeIgniter\Model;
/**
 * LoginModel class.
 * 
 * @extends CI_Model
 */
class LoginModel extends Model {
	public function loginCheck($username,$password) {
		
		$builder = $this->db->table('admin'); // Get builder for a specific table
        $builder->select('*');
		$builder->where('username', $username);
		$builder->where('password', encrypt_password($password));
		
        $query = $builder->get(); // Runs the query

        return $query->getResult(); // Get results as an array of arrays
	}
	public function changePassword($id,$password) {
		$data = [
			'password'  => $password
		];
		$builder = $this->db->table('admin'); // Get builder for a specific table
		$builder->where('id', $id);
		if($builder->update($data)){ return 1;}
		else{return 0;}
	}
}