<?php

namespace App\Jobs;

use App\Mail\UserCreation;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Mail;

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

    /**
     * Create a new job instance.
     */
    public $user;
    public $password;
    public $login_url;
    public function __construct($my_user, $my_password, $url)
    {
        $this->user = $my_user;
        $this->password = $my_password;
        $this->login_url = $url;
    }

    /**
     * Execute the job.
     */
    public function handle(): void
    {
        Mail::send(new UserCreation($this->user, $this->password, $this->login_url));
    }
}
