<?php

namespace App\Models;

use CodeIgniter\Model;

class SharnarthiModel extends Model
{

    public function get_all_camp()
    {
        return $this->db->table('sharnarthi_camp')
        ->get()
        ->getResult();
    }

    public function get_all_camp_by_added_by($id)
    {
        return $this->db->table('sharnarthi_camp')
        ->where('camp_added_by', $id)
        ->get()
        ->getResult();
    }

    public function add_camp($data)
    {
        return $this->db->table('sharnarthi_camp')
        ->insert($data);
    }

    public function get_camp_by_id($id)
    {
        return $this->db->table('sharnarthi_camp')
        ->where('camp_id', $id)
        ->get()
        ->getRow();
    }

    public function update_camp($data, $id)
    {
        return $this->db->table('sharnarthi_camp')
        ->where('camp_id', $id)
        ->update($data);
    }

    public function delete_camp($id)
    {
        return $this->db->table('sharnarthi_camp')
        ->where('camp_id', $id)
        ->delete();
    }

    public function add_camp_review($data, $id)
    {
        return $this->db->table('sharnarthi_camp')
        ->where('camp_id', $id)
        ->update($data);
    }

    public function check_camp_avaliablity($id)
    {
        return $this->db->table('sharnarthi_camp')
        ->where('camp_pin_code', $id)
        ->get()
        ->getNumRows();
    }

    //// Camp Section End /////////////////////////////////////////

    public function get_all_state()
    {
        return $this->db->table('state')
        ->get()
        ->getResult();
    }

    function get_all_sharnarthi()
    {
        return $this->db->table('sharnarthi')
        ->get()
        ->getResult();
    }

    function get_all_sharnarthi_by_added_by($id)
    {
        return $this->db->table('sharnarthi')
        ->where('sharnarthi_added_by', $id)
        ->get()
        ->getResult();
    }

    public function add_sharnarthi($data)
    {
        return $this->db->table('sharnarthi')
        ->insert($data);
    }

    public function get_sharnarthi_by_id($id)
    {
        return $this->db->table('sharnarthi')
        ->where('sharnarthi_id', $id)
        ->get()
        ->getRow();
    }

    public function delete_sharnarthi($id)
    {
        return $this->db->table('sharnarthi')
        ->where('sharnarthi_id', $id)
        ->delete();
    }

    

}
