<?php
namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Messages\MailMessage;

class NewBookingNotification extends Notification
{
    use Queueable;

    public $booking;

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

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

    public function toMail($notifiable)
    {
        $frontendUrl = env('FRONTEND_URL', 'https://midhouse.id');
        return (new MailMessage)
            ->subject('Pemberitahuan: Ada Booking Baru Masuk!')
            ->greeting('Halo Admin!')
            ->line('Ada pesanan baru nih dengan detail sebagai berikut:')
            ->line('📄 Nomor Invoice: ' . $this->booking->invoice_id)
            ->line('👤 Nama Penyewa: ' . $this->booking->user->name)
            ->line('🏘️ Kode Kamar: ' . $this->booking->room->kode_kamar)
            ->line('📅 Tanggal Check-in: ' . $this->booking->checkin)
            ->line('💰 Total Harga: Rp ' . number_format($this->booking->total_price, 0, ',', '.'))
            ->action('Lihat Detail Booking', 'https://midhouse.id/dashboard/kelola-booking')
            ->line('Jangan lupa segera diproses ya, Min!');
    }
}
