<?php
class FamilyModel extends CI_Model {
    public function __construct() {
        $this->load->database();
    }

    public function get_family_members() {
        $query = $this->db->get('family_members');
        return $query->result_array();
    }

    public function get_father(){
        $query = $this->db->get('family_members');
        $this->db->where('gender', 'male');
        return $query->result_array();
    }

    public function get_mother(){
        $query = $this->db->get('family_members');
        $this->db->where('gender', 'female');        
        return $query->result_array();
    }


    public function tambah_family_member($data)
    {        
        $this->db->insert('family_members', $data);
    }

    public function update_photo($member_id, $photo_url)
    {
        // Update kolom foto berdasarkan ID anggota keluarga
        $data = [
            'photo' => $photo_url,
        ];

        // Update foto di tabel family_members berdasarkan member_id
        $this->db->where('id', $member_id);
        return $this->db->update('family_members', $data);
    }

    public function update_family_member($member_id, $data) {
        // Menyimpan data ke tabel family_members
        $this->db->where('id', $member_id);
        return $this->db->update('family_members', $data);
    }


}