<?php

namespace Yajny\MailYj\Mails;

use Illuminate\Support\Facades\Cache;
use Yajny\Member\Models\Currencies;

class UpdatePayoutEmail extends BaseMail
{
    public $user;
    public $template_name;
    public $lang;
    public $payout;
    public $payoutCurrency;
    public $latestOffer;

    /**
     * Create a new message instance.
     *
     * @param $user
     * @param $payout
     */
    public function __construct($user, $payout, $latestOffer)
    {
        $allCurrencies = Cache::rememberForever('currencies', function () {
            return Currencies::all()->mapWithKeys(function ($currency) {
                return [$currency->iso_code => $currency];
            });
        });

        $this->user = $user;
        $this->payout = $payout;
        $this->latestOffer = $latestOffer;
        $this->template_name = 'member.payout.update';
        $this->lang = $user->user_lang;
        $this->payoutCurrency = $allCurrencies[$payout->local_currency];
        parent::__construct();
    }
}
