<?php

namespace App\Notifications;

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

class NewPaymentNotification extends Notification
{
    use Queueable;

    protected $payment;

    public function __construct(Payment $payment)
    {
        $this->payment = $payment;
    }

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

    public function toMail($notifiable)
    {
        $url = env('FRONTEND_URL', 'https://midhouse.id') . '/dashboard/kelola-pembayaran'; // link frontend admin

        return (new MailMessage)
            ->subject('Pemberitahuan: Bukti Pembayaran Baru Diterima!')
            ->greeting('Halo Admin!')
            ->line('Seorang penyewa baru saja mengirimkan bukti pembayaran.')
            ->line('📄 Nomor Invoice: ' . $this->payment->invoice_id)
            ->line('👤 Nama Pengirim: ' . optional($this->payment->user)->name)
            ->line('🏦 Bank Asal: ' . $this->payment->nama_bank . ' a.n ' . $this->payment->atas_nama)
            ->line('💰 Nomor Rekening: ' . $this->payment->norek)
            ->action('Verifikasi Pembayaran', $url)
            ->line('Mohon segera dicek dan diverifikasi.')
            ->salutation('Salam, MidHouse System');
    }
}
