<?php

namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Mail\SendFeedbackMail;
use Illuminate\Support\Facades\Mail;

class FeedbackController extends Controller
{

    public function sendEmail(Request $request)
    {
        $name = $request->input('name');
        $email = $request->input('email');
        $subject = $request->input('subject');
        $message = $request->input('message');

        $data = ['name' => $name,'email'=> $email,'message'=> $message, 'subject' => $subject ];

        Mail::send('mails.feedback', [ 'data' => $data ], function($message) {
            $message->to('jaro@ttx.sk', 'Jaroslv Drzik')
                    ->to('marosholub@gmail.com','Maros Holub')
                    ->subject('IKEA Feedback Mail');
         });

        return response()->json(['success' => 'Send email successfully.']);
    }
}
