<?php

namespace App\Http\Controllers;

class MailController extends Controller
{
    public function welcome($user)
    {
        return \Illuminate\Support\Facades\Mail::to($user->email)->send(new \App\Mail\WelcomeMail($user));
    }
     
    public function purchase($user, $currency, $amount, $tx_id)
    {
        return \Illuminate\Support\Facades\Mail::to($user->email)->send(new \App\Mail\PurchaseMail($user, $currency, $amount, $tx_id));
    }

    public function finance($user, $currency, $price, $amount, $tx_id)
    {
        return \Illuminate\Support\Facades\Mail::to($user->email)->send(new \App\Mail\FinanceMail($user, $currency, $price, $amount, $tx_id));
    }

    public function custom($recipient, $subject, $body)
    {
        if (is_array($recipient)) {
            foreach ($recipient as $receiver) {
                \Illuminate\Support\Facades\Mail::to($receiver)->send(new \App\Mail\CustomMail($subject, $body));
            }
        } else {
            return \Illuminate\Support\Facades\Mail::to($recipient)->send(new \App\Mail\CustomMail($subject, $body));
        }
    }
}
