<?php

namespace App\Models;

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

class Order extends Model
{
    use HasFactory;

    protected $fillable = [
        'user_id',
        'order_number',
        'status',
        'payment_status',
        'order_status',
        'subtotal',
        'discount',
        'shipping_fee',
        'total',
        'currency',
        'payment_method',
        'shipping_detail',
        'customer_name',
        'customer_phone',
        'customer_email',
        'note',
        'transaction_id',
        'approval_code',
        'paid_at',
        'cancelled_at',
        'completed_at',
        'shipping_method_id',
        'shipping_method_name',
        'shipping_method_code',
    ];

    /**
     * Get the items for the order.
     */
    public function items()
    {
        return $this->hasMany(OrderItem::class);
    }

    /**
     * Get the user that owns the order.
     */
    public function user()
    {
        return $this->belongsTo(User::class);
    }

    /**
     * Get the shipping method for the order.
     */
    public function shippingMethod()
    {
        return $this->belongsTo(ShippingMethod::class);
    }
}
