<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use \App\Helpers\PageSL; 
use App\User;
use Session;
use Mail;
 

class AjaxController extends Controller
{
    public function get($name, Request $req)
	{ 
		if ($name == 'test') { 
			 
		}
	}

	public function post($name, Request $req)
	{
		if($name =='send_apply_student_teacher_email') {  
			  
			 $user =User::find($req->id);
			 if($user){
				$data['name'] = $user->first_name.' '.$user->last_name;  
				$user_mail =$user->email;
				$from = 'test@mail.com'; 
				Mail::send('email.send_apply_student_teacher_email',$data, function ($message) use ($user_mail,$from) {
					$message->from($from);
					$message->to($user_mail)->subject('New Email Send to you');
				});
			 }

            return ['msg'=>'Email send successfully.'];

		}  
	}
}
