<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class ListingTransfer extends Model
{
    public const TRANSFER_APPROVED_STATUS = 'approved';
    public const TRANSFER_PENDING_STATUS = 'pending';
    public const TRANSFER_REJECTED_STATUS = 'rejected';

    protected $fillable = [
        'listing_id',
        'sender_company_id',
        'receiver_company_id',
        'receiver_consultant_id',
        'transfer_type',
        'amount',
        'description',
        'status'
    ];

    public function listing()
    {
        return $this->belongsTo(Listing::class);
    }

    public function sender_company()
    {
        return $this->belongsTo(Company::class);
    }

    public function receiver_company()
    {
        return $this->belongsTo(Company::class);
    }

    // Gönderenin önerdiği hedef danışman (panelde adıyla gösterilir)
    public function receiver_consultant()
    {
        return $this->belongsTo(ConsultantProfile::class);
    }

    public function scopeApproved($query)
    {
        return $query->where('status',$this::TRANSFER_APPROVED_STATUS);
    }
    
    public function scopePending($query)
    {
        return $query->where('status',$this::TRANSFER_PENDING_STATUS);
    }

    public function scopeRejected($query)
    {
        return $query->where('status',$this::TRANSFER_REJECTED_STATUS);
    }

    

}
