<?php

namespace App\Models;

use CodeIgniter\Model;

class PurchaseOrderModel extends Model
{
    protected $table          = 'purchase_orders';
    protected $primaryKey     = 'id';
    protected $allowedFields  = ['po_number','supplier_id','status','order_date','expected_date','subtotal','tax','total','notes'];
    protected $useTimestamps  = true;
    protected $useSoftDeletes = true;

    protected $validationRules = [
        'po_number'   => 'required|max_length[60]|is_unique[purchase_orders.po_number,id,{id}]',
        'supplier_id' => 'required|is_natural_no_zero',
        'status'      => 'in_list[draft,ordered,received,canceled]',
    ];
}
