<?php

class Agent_model extends CI_Model {

    public $rules=array(
	'first_name' => array('field' => 'first_name', 'label' => 'First Name','rules' => 'trim|required|min_length[2]|max_length[30]'),
	'last_name' => array('field' => 'last_name', 'label' => 'Last Name','rules' => 'trim|required|min_length[2]|max_length[30]'),
	'username' => array('field' => 'username', 'label' => 'Username','rules' => 'trim|required|min_length[4]|max_length[15]|is_unique[users.username]'),
	'email' => array('field' => 'email', 'label' => 'Email','rules' => 'trim|required|valid_email|callback__unique_email'),
	'password' => array('field' => 'password', 'label' => 'Password','rules' => 'trim|required|min_length[5]|max_length[12]'));

	public function get_all(){
	  $this->db->select('*');
	  $this->db->from('users');
	  $this->db->where('user_type','agent');
	  $query=  $this->db->get();
	  return $query->result();
	}
	
	public function get_by($id){
	  $this->db->select('*');
	  $this->db->from('users');
	  $this->db->where('id',$id);
	  $query=  $this->db->get();
	  return $query->row();
	}

}