<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class DetailPembayaran extends Model
{
    protected $table = 'detail_pembayaran';

    protected $fillable = [
        'transaksi_pembayaran_id',
        'tagihan_id',
        'jumlah_bayar',
    ];

    protected $casts = [
        'jumlah_bayar' => 'decimal:2',
    ];

    protected static function booted()
    {
        // Payment handling moved to DetailPembayaranObserver; no action here.
        static::created(function ($detail) {
            // No operation needed.
        });
    }

    public function transaksiPembayaran(): BelongsTo
    {
        return $this->belongsTo(TransaksiPembayaran::class);
    }

    public function tagihan(): BelongsTo
    {
        return $this->belongsTo(Tagihan::class);
    }
}
