<?php

namespace nota\models;

use Yii;

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

    public function rules()
    {
        return [
            [['kode', 'nama', 'harga', 'stok', 'status'], 'required'],
            [['harga', 'diskon'], 'number'],
            [['stok', 'minimal_stok', 'ppn', 'kategori_id'], 'integer'],
            [['deskripsi'], 'string'],
            [['kode'], 'string', 'max' => 50],
            [['nama'], 'string', 'max' => 150],
            [['satuan'], 'string', 'max' => 20],
            [['status'], 'in', 'range' => ['aktif','nonaktif']],
            [['gambar'], 'string', 'max' => 255],
        ];
    }
}
