<?php

namespace App\Classes\Jobs;

use App\Classes\Notifications\UserVerificationEmail;
use App\Models\User;
use App\Models\UserEmailVerification;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

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


    /** @var User */
    private $user;

    /** @var UserEmailVerification */
    private $attempt;

    /**
     * SendUserVerificationEmail constructor.
     * @param User $user
     * @param UserEmailVerification $attempt
     */
    public function __construct(User $user, UserEmailVerification $attempt)
    {
        $this->user = $user;
        $this->attempt = $attempt;
    }


    public function handle()
    {
        $this->user->notify(new UserVerificationEmail($this->user, $this->attempt));
    }
}
