db->get_where('invoices', array('id' => (int) $id))->row(); } public function createDraft(array $data) { $data['status'] = 'draft'; if (!$this->db->insert('invoices', $data)) { throw new RuntimeException('Gagal membuat draft invoice.'); } return (int) $this->db->insert_id(); } public function updateById($id, array $data) { return $this->db->where('id', (int) $id)->update('invoices', $data); } }