<?php

namespace App\Jobs;

use App\Mail\TourPurchaseConfirmation;
use App\Models\TourPurchase;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Mail;

class SendTourPurchaseConfirmation implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public TourPurchase $purchase;

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

    public function handle(): void
    {
        Mail::to($this->purchase->customer_email)
            ->send(new TourPurchaseConfirmation($this->purchase));
    }
}
