<?php

namespace App\Models;

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

class Order extends Model
{
    protected $fillable = [
        'user_id',
        'instrument_id',
        'broker_order_no',
        'exchange',
        'tradingsymbol',
        'transaction_type',
        'product_type',
        'price_type',
        'quantity',
        'price',
        'trigger_price',
        'avg_price',
        'filled_quantity',
        'status',
        'remarks',
        'placed_at',
    ];

    protected function casts(): array
    {
        return [
            'placed_at' => 'datetime',
        ];
    }

    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }

    public function instrument(): BelongsTo
    {
        return $this->belongsTo(Instrument::class);
    }
}
