<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class BilPelbagai extends Model
{
    use HasFactory;

    protected $fillable = [
        'cara_jana', 
        'lesen_penjaja_id', 
        'status_mylesen', 
        'status_mylesen_error', 
        'ref_no', 
        'description', 
        'pay_status', 
        'jabatan', 
        'gst_rate', 
        'client_key', 
        'ent_opr', 
        'client_type', 
        'status_epbt', 
        'return_param', 
        'no_bilpelbagai', 
        'no_akaun_bilpelbagai', 
        'dt_bayar', 
        'no_resit', 
        'amaun_bayar', 
        'catatan'
    ];


    public function bil_pelbagai_item(){
        return $this->hasMany(BilPelbagaiItem::class);
    }
    

    public function amaun_bil(){
        $jumlah = BilPelbagaiItem::where('bil_pelbagai_id', $this->id)->sum('itemprice');

        return $jumlah;
    }
}
