app/Http/Controllers/RequestInfoController.php
/**
	 * Validates the form request and sends an email.
	 *
	 * @param RequestInfoFormRequest $request
	 * @return Illuminate\View\View
	 */
Validates the form request and sends an email.
@param RequestInfoFormRequest $request
@return Illuminate\View\View
Validates the form request and sends an email . @param RequestInfoFormRequest $request @return Illuminate \ View \ View
public function store(RequestInfoFormRequest $request)
	{
		$customer = Customer::where('email', $request->get('email'))->first();
		if (!$customer instanceof Customer) {
			$customer = new Customer($request->all());
			if (!$customer->save()) {
				return back()->withInput()->with('alert', ['status' => 'danger', 'message' => 'There was an error submitting your request. Please try again later.']);
			}
			$subject = 'Interactive Curriculum Information Request - New Customer';
		} else {
			$subject = 'Interactive Curriculum Information Request - Existing Customer';
		}
		Mail::send('email.request_info', [
			'customer' => $customer
		], function($message) use ($customer, $subject) {
			$message->from($customer->email, $customer->name);
			$message->to(self::POSTMASTER_EMAIL, self::POSTMASTER_NAME)->subject($subject);
		});
		return redirect()->route('request_info')->with('alert', ['status' => 'success', 'message' => "Thank you for your interest! We'll get back to you with more information shortly."]);
	}
public function store ( RequestInfoFormRequest $ request ) { $ customer = Customer :: where ( 'email' , $ request -> get ( 'email' ) ) -> first ( ) ; if ( ! $ customer instanceof Customer ) { $ customer = new Customer ( $ request -> all ( ) ) ; if ( ! $ customer -> save ( ) ) { return back ( ) -> withInput ( ) -> with ( 'alert' , [ 'status' => 'danger' , 'message' => 'There was an error submitting your request. Please try again later.' ] ) ; } $ subject = 'Interactive Curriculum Information Request - New Customer' ; } else { $ subject = 'Interactive Curriculum Information Request - Existing Customer' ; } Mail :: send ( 'email.request_info' , [ 'customer' => $ customer ] , function ( $ message ) use ( $ customer , $ subject ) { $ message -> from ( $ customer -> email , $ customer -> name ) ; $ message -> to ( self :: POSTMASTER_EMAIL , self :: POSTMASTER_NAME ) -> subject ( $ subject ) ; } ) ; return redirect ( ) -> route ( 'request_info' ) -> with ( 'alert' , [ 'status' => 'success' , 'message' => " Thank you for your interest! We'll get back to you with more information shortly. " ] ) ; }
Validates the form request and sends an email.
Validates the form request and sends an email .