Files
2026-09-11 16:03:00 +07:00

25 lines
647 B
PHP

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class InvoiceModel extends CI_Model
{
public function find($id)
{
return $this->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);
}
}