<?php

namespace App\Mail;

use App\Models\Booking;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;

class BookingStatusChanged extends Mailable
{
    use Queueable, SerializesModels;

    public $booking;
    public $oldStatus;

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

    public function envelope(): Envelope
    {
        $subject = 'Booking Status Update - Hotel Bardan Boutique';
        
        if ($this->booking->status === 'confirmed') {
            $subject = 'Booking Confirmed - Hotel Bardan Boutique';
        } elseif ($this->booking->status === 'cancelled') {
            $subject = 'Booking Cancelled - Hotel Bardan Boutique';
        }
        
        return new Envelope(
            subject: $subject,
        );
    }

    public function content(): Content
    {
        return new Content(
            view: 'emails.booking-status-changed',
        );
    }

    public function attachments(): array
    {
        return [];
    }
}

