<?php

namespace App\Models;

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

class TransactionDetail extends Model
{
    use HasFactory;

    protected $table = 'transaction_details';

    protected $fillable = [
        'transaction_id', 
        'item_id', 
        'item_variant_id', 
        'item_reference_id', 
        'qty', 
        'unit', 
        'unit_price', 
        'unit_cost',
        'point',
        'discount',
        'total',
    ];

    public function item()
    {
        return $this->belongsTo(Items::class, 'item_id', 'id');
    }

    public function reference() {
        return $this->belongsTo(ItemReference::class, 'item_reference_id', 'id');
    }
}
