<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\URL;
use App\Mail\UserContact;

class EmailController extends Controller
{
    public function sendContactMail(Request $request){
    	$this->validate($request,[
    		'g-recaptcha-response' => 'required|captcha',
    		'name' => 'required',
    		'contact' => 'required',
    		'subject' => 'required',
    		'message' => 'required'
    	]);
    	$data = array(
    		'name' => $request->name,
    		'contact' => $request->contact,
    		'subject' => $request->subject,
    		'message' => $request->message
    	);
    	Mail::to('info@amgroup.com.np')->send(new UserContact($data));
    	flash('<p style="font-size:1.2rem" class="text-center text-success">Thank you for contacting us. We have recieved your message and will reach back to you as soon as possible!</p>')->success();
    	return redirect()->back();
    }
}
