<?php

namespace App\Models;

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

class SaleItem extends Model
{
    use HasFactory;

    protected $fillable = [
        'sale_id',
        'product_id',
        'barcode',
        'name',
        'size',
        'color',
        'quantity',
        'unit_price',
        'cost_price',
        'discount',
        'gst_rate',
        'total',
    ];

    protected $casts = [
        'unit_price' => 'float',
        'cost_price' => 'float',
        'discount' => 'float',
        'gst_rate' => 'float',
        'total' => 'float',
        'quantity' => 'integer',
    ];

    public function sale()
    {
        return $this->belongsTo(Sale::class);
    }

    public function product()
    {
        return $this->belongsTo(Product::class);
    }
}
