<?php

namespace App\Models;

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

class TradeJournal extends Model
{
    protected $table = 'trade_journal';

    protected $fillable = [
        'user_id', 'instrument_id', 'regime', 'entry_conditions', 'entry_price', 'exit_price', 'pnl', 'confidence', 'entered_at', 'exited_at',
    ];

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

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