<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class ForgotPasswordMail extends Mailable
{
    use Queueable, SerializesModels;

    public $newPassword; // New password for the user
    public $email; // User's email
    public $siteName; // Site name from settings
    public $appUrl; // Application URL

    /**
     * Create a new message instance.
     *
     * @param string $newPassword
     * @param string $email
     * @param string $siteName
     * @param string $appUrl
     */
    public function __construct($newPassword, $email, $siteName, $appUrl)
    {
        $this->newPassword = $newPassword;
        $this->email = $email;
        $this->siteName = $siteName;
        $this->appUrl = $appUrl;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->subject('Your New Password - ' . $this->siteName)
                    ->view('emails.forgot_password')
                    ->with([
                        'newPassword' => $this->newPassword,
                        'email' => $this->email,
                        'siteName' => $this->siteName,
                        'appUrl' => $this->appUrl,
                    ]);
    }
}
