<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class ItemDb extends Model
{
    protected $table = 'items_data_base';
    protected $appends = ['price'];


    protected $fillable = [
        'Key',
        'No',
        'Size',
        'Search_Description',
        'Description',
        'Division_Code',
        'Item_Category_Code',
        'Unit_Price',
        'Unit_Price_Including_VAT',
        'Price_Includes_VAT',
        'Base_Unit_of_Measure',
        'DefaultBarcode',
        'Barcode_Mask',
        'Special_Group_Code',
        'Blocked',
        'Type',
        'Item_Family_Code',
        'Date_Created',
        'Created_by_User',
        'Last_Date_Modified',
        'Last_Modified_by_User',
        'Costing_Method',
        'Standard_Cost',
        'Unit_Cost',
        'Last_Direct_Cost',
        'Price_Profit_Calculation',
        'Profit_Percent',
        'POS_Cost_Calculation',
        'Profit_Goal_Percent',
        'Inventory_Posting_Group',
        'Gen_Prod_Posting_Group',
        'Vendor_No',
        'Vendor_Item_No',
        'Purch_Unit_of_Measure',
        'Gender',
        'Subcategory',
        'Color',
        'Country',
    ];

    public function brand()
    {
        return $this->belongsTo(BrandDb::class, 'Item_Family_Code', 'Code');
    }
    public function getPriceAttribute()
    {
        return (int) (float) $this->Unit_Price_Including_VAT;
    }
}
