<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class SaasPayment extends Model
{
    protected $table = 'saas_payments';

    protected $fillable = [
        'payment_number',
        'tenant_id',
        'invoice_id',
        'payment_date',
        'amount',
        'payment_method',
        'transaction_reference',
        'proof_attachment',
        'status',
        'remarks',
        'received_by',
    ];

    protected $casts = [
        'payment_date' => 'date',
    ];

    public function tenant()
    {
        return $this->belongsTo(Tenant::class);
    }

    public function invoice()
    {
        return $this->belongsTo(SaasInvoice::class, 'invoice_id');
    }

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