<?php

namespace App\Modules\Integration\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;

class SalesOrder extends Model
{
    protected $table = 'sales_orders';

    protected $fillable = [
        'external_order_id',
        'status',
        'payment_method',
        'total_amount',
        'sold_at',
        'raw_payload',
    ];

    protected $casts = [
        'sold_at' => 'datetime',
        'raw_payload' => 'array',
        'total_amount' => 'decimal:4',
    ];

    public function items(): HasMany
    {
        return $this->hasMany(SalesOrderItem::class);
    }
}
