<?php

namespace nota\models;

use Yii;

class NotaItem extends \yii\db\ActiveRecord
{
    public static function getDb() {
        return Yii::$app->get('dbnota'); 
    }
    
    public static function tableName()
    {
        return 'nota_item';
    }

   public function rules()
    {
        return [
          [['barang_id','qty','harga'],'required'],
          [['barang_id','qty'],'integer'],
          [['harga','subtotal'],'number'],
        ];
    }

    public function getBarang()
    {
       return $this->hasOne(Barang::class,['id'=>'barang_id']);
    }

    public function getNota()
    {
        return $this->hasOne(Nota::class, ['id' => 'nota_id']);
    }


}
