<?php

namespace App\Models;

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

class PurchaseDetails extends BaseModel
{
    use HasFactory;

    protected $guarded = [];

    public function attribute()
    {
        return $this->hasOne(productAttribute::class, 'id', 'attribute_id')->with('color', 'unit', 'brand', 'product', 'warehouse.warehouse','diamondUnit','goldUnit');
    }

    public function product()
    {
        return $this->hasOne(product::class, 'id', 'product_id');
    }

    public function returnProduct()
    {
        return $this->hasMany(PurchaseReturnDetails::class, 'purchase_invoice_no', 'purchase_master_id');
    }

    public function purchaseMaster()
    {
        return $this->hasOne(PurchaseMaster::class, 'id', 'purchase_master_id')->with('warehouse');
    }
}
