<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use OwenIt\Auditing\Contracts\Auditable;

class Meeting extends Model implements Auditable
{
    use HasFactory, SoftDeletes;
    use \OwenIt\Auditing\Auditable;

    protected $fillable = [
        'code', 'investor_id', 'admin_id', 'proposal_id', 'opportunity_id',
        'title', 'description', 'status', 'type', 'location', 'meeting_url',
        'requested_at', 'scheduled_at', 'completed_at',
        'rejection_reason', 'meeting_notes',
    ];

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

    public function investor(): BelongsTo { return $this->belongsTo(User::class, 'investor_id'); }
    public function admin(): BelongsTo { return $this->belongsTo(User::class, 'admin_id'); }
    public function proposal(): BelongsTo { return $this->belongsTo(InvestmentProposal::class); }
    public function opportunity(): BelongsTo { return $this->belongsTo(InvestmentOpportunity::class); }
}
