<?php

// app/Models/OrderItemModel.php

namespace App\Models;

use CodeIgniter\Model;

class StockIn extends Model
{
    protected $table = 'stockin';
    protected $primaryKey = 'id';
    protected $allowedFields = ['product_id', 'date_time', 'qty', 'image', 'qty_temp', 'approval'];
    
    public function addstock($data)
    {
        return $this->insert($data);
    }
    public function getTotalBarangMasuk($productId)
    {
        return $this->selectSum('qty')
        ->where('product_id', $productId)
        ->first()['qty'];
    }
}