<?php

namespace App\Mail;

use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class WelcomeUserMail extends Mailable
{
    use Queueable, SerializesModels;

    public User $user;
    public string $password;
    public $loginUrl;

    public function __construct(User $user, string $password)
    {
        $this->user = $user;
        $this->password = $password;
        $this->loginUrl = config('app.url') . '/admin/login'; // URL dinámica
    }

    public function build()
    {
        return $this->subject('Bienvenido a la plataforma')
            ->view('emails.welcome-user')
            ->with([
                'name' => $this->user->name,
                'email' => $this->user->email,
                'password' => $this->password,
                'loginUrl' => $this->loginUrl, 
            ]);
    }
}
