<?php

namespace App\Mail;

use App\Facade\Theme;
use App\Facade\UserConfig;
use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class ResetMyPassword extends MailableBase
{
    use Queueable, SerializesModels;

    private $token;
    private $user;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct(User $user, $token)
    {
        $this->user = $user;
        $this->token = $token;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        $subject = trans('email.reset_my_password_subject', ['app_name' => UserConfig::get('app_name')]);

        return $this
            ->subject($subject)
            ->markdown(Theme::viewName('email.reset_my_password'))
            ->with([
                'subject' => $subject,
                'token' => $this->token,
                'user' => $this->user
            ]);
    }
}