<?php

namespace App\Jobs;

use App\Mail\PackageOrderAdminMail;
use App\Mail\PackageOrderUserMail;
use App\Models\OrderPackage;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;
use Illuminate\Support\Facades\Mail;

class ProcessPackageOrder implements ShouldQueue
{
    use Queueable;
public OrderPackage $order;

    /**
     * Create a new job instance.
     */
    public function __construct(OrderPackage $order)
    {
        $this->order = $order;
    }


    /**
     * Execute the job.
     */
    public function handle(): void
    {
        Mail::to($this->order->user->email)->send(new PackageOrderUserMail($this->order));
        Mail::to(env('ADMIN_EMAIL'))->send(new PackageOrderAdminMail($this->order));

    }
}
