<?php

namespace App\Mail;

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

class ResetPasswordMail extends Mailable
{
    use Queueable, SerializesModels;

    public $mailer = 'system';

    public function __construct(
        public User   $user,
        public string $token,
    ) {}

    public function envelope(): Envelope
    {
        return new Envelope(
            subject: 'Passwort zurücksetzen — Aziros',
        );
    }

    public function content(): Content
    {
        $url = url('/password/reset/' . $this->token . '?email=' . urlencode($this->user->email));

        return new Content(
            view: 'emails.reset-password',
            with: ['url' => $url, 'user' => $this->user],
        );
    }
}
