<?php

namespace App\Classes\Notifications;


use App\Models\User;
use App\Models\Voucher;
use Carbon\Carbon;
use Illuminate\Notifications\Messages\MailMessage;

class WelcomeVoucherEmail extends AbstractEmail
{

    /** @var User */
    private $user;

    /** @var Voucher */
    private $voucher;

    /**
     * WelcomeVoucherEmail constructor.
     * @param User $user
     * @param Voucher $voucher
     */
    public function __construct(User $user, Voucher $voucher)
    {
        $this->user = $user;
        $this->voucher = $voucher;
    }


    public function toMail()
    {
        $this->voucher->end_date = Carbon::parse($this->voucher->end_date)->format('Y-m-d');
        $mailMessage =  (new MailMessage)
                        ->subject('Welcome Voucher')
                        ->view('emails.accounts.welcome_voucher', ['user' => $this->user, 'voucher' => $this->voucher]);

        return $mailMessage;
    }


}
