<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Transfer extends Model
{
    use HasFactory;

    protected $fillable = [
        'user_id', // For backward compatibility
        'sender_id',
        'recipient_id',
        'amount',
        'destination',
        'description',
        'reference',
        'status',
        'admin_notes',
        'processed_at'
    ];

    protected $casts = [
        'processed_at' => 'datetime'
    ];

    public function sender(){
        return $this->belongsTo(User::class, 'sender_id');
    }

    public function recipient(){
        return $this->belongsTo(User::class, 'recipient_id');
    }

    public function user(){
        return $this->belongsTo(User::class, 'sender_id'); // For backward compatibility
    }
}
