<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Order extends Model
{
    protected $casts = [
        'note_attributes' => 'json',
        'total' => 'float',
        'order_created_at' => 'datetime:Y-m-d\TH:i:sT',
        'order_updated_at' => 'datetime:Y-m-d\TH:i:sT',
        'total_tax' => 'float',
        'total_discount' => 'float',
        'tax_info' => 'json'
    ];

    public function company()
    {
        return $this->belongsTo(Company::class);
    }

    public function customer()
    {
        return $this->belongsTo(Customer::class);
    }

    public function orderItems()
    {
        return $this->hasMany(OrderItem::class);
    }
}
