<?php
// app/Notifications/PaymentApprovedNotification.php
namespace App\Notifications;

use App\Models\Payment;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Messages\MailMessage;

class PaymentApprovedNotification extends Notification
{
    use Queueable;

    public function __construct(private Payment $payment) {}

    public function via($notifiable) { return ['mail']; }

    public function toMail($notifiable)
    {
        $b      = $this->payment->booking;          // relasi booking
        $room   = $b?->room?->kode_kamar ?? '-';
        $link   = env('FRONTEND_URL', 'https://midhouse.id') . '/dashboard/pembayaran';

        return (new MailMessage)
            ->subject('Pembayaran Kamu Sudah Dikonfirmasi! ✅')
            ->greeting('Halo ' . $notifiable->name . ' 👋')
            ->line('Kabar gembira! Pembayaran untuk invoice **' . $this->payment->invoice_id . '** sudah kami verifikasi dan kamar kamu sudah aktif.')
            ->line('🔑 Kode Kamar : ' . $room)
            ->line('📅 Masa Sewa : ' . $b?->start_date . ' – ' . $b?->end_date)
            ->action('Lihat Detail Booking', $link)
            ->salutation('Terima kasih, Tim MidHouse Universe');
    }
}
