<?php

namespace App\Models;

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

class OrderAdditionalCost extends Model
{
    use HasFactory;

    protected $table = 'order_additional_costs';

    protected $fillable = [
        'order_id',
        'client_id',
        'seed_id',
        'item_name',
        'category',
        'unit',
        'quantity',
        'unit_price',
        'total_price',
        'item_notes',
        'order_notes',
        'gross_total',
        'additional_costs_total',
        'final_total'
    ];

    protected $casts = [
        'quantity' => 'decimal:2',
        'unit_price' => 'decimal:2',
        'total_price' => 'decimal:2',
        'gross_total' => 'decimal:2',
        'additional_costs_total' => 'decimal:2',
        'final_total' => 'decimal:2',
    ];

    // Relationships
    public function order()
    {
        return $this->belongsTo(Order::class);
    }

    public function client()
    {
        return $this->belongsTo(Client::class);
    }

    public function seed()
    {
        return $this->belongsTo(Seed::class);
    }
}
