<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class SaleItem extends Model
{
    protected $fillable = [
        'sale_id', 'product_id', 'sku', 'product_name',
        'qty', 'price', 'subtotal', 'is_free',
    ];

    protected function casts(): array
    {
        return [
            'qty'      => 'integer',
            'price'    => 'integer',
            'subtotal' => 'integer',
            'is_free'  => 'boolean',
        ];
    }

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

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