<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use App\Traits\GlobalModelEvents;

class Sell extends Model
{
    use HasFactory, GlobalModelEvents;

    protected $fillable = [
        // Original columns
        'user_id', 'ownership_id', 'product_id', 'market_id', 'investment_id',
        'initial_price', 'amount', 'quantity', 'status', 'type', 'sell_time',
        'wallet_source',
        // NEXUS columns (added Phase 1 migration, registered Phase 2)
        'margin_percent', 'recess_percent', 'excess_percent',
        'fill_price', 'nexus_session_id', 'rejection_reason',
    ];

    public function product()
    {
        return $this->belongsTo(Product::class);
    }

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

    public function investment()
    {
        return $this->belongsTo(Investment::class);
    }

    public function ownership()
    {
        return $this->belongsTo(Ownership::class);
    }

    public function market()
    {
        return $this->belongsTo(Market::class);
    }
}
