<?php

namespace App\Jobs;

use App\Http\Controllers\Admin\MailController;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

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

    public function __construct(
        public string $username,
        public string $firstName,
        public string $email,
        public int    $userId,
    ) {}

    public function handle(): void
    {
        $mail = new MailController();
        $mail->storeSetup($this->username, $this->firstName, $this->email);

        User::where('id', $this->userId)->update(['activated' => 1]);
    }
}