<?php



namespace App\Models;



use CodeIgniter\Model;



class Opname extends Model

{

    protected $table = 'opname';

    protected $primaryKey = 'id'; // Assuming your primary key field name is 'id'

    protected $allowedFields = ['stock', 'guid', 'keterangan', 'product_id', 'qty', 'status', 'img', 'created_date', 'modified_date', 'users_id'];
   
    public function getTotalOpname($productId)
    {
        return $this->selectSum('qty')
        ->where('product_id', $productId)
        ->first()['qty'];
    }
  
}

