Skip to content

Instantly share code, notes, and snippets.

@DuffleOne
Created January 22, 2015 02:35
Show Gist options
  • Save DuffleOne/9174ec2c0482b3ba7a10 to your computer and use it in GitHub Desktop.
Save DuffleOne/9174ec2c0482b3ba7a10 to your computer and use it in GitHub Desktop.
<?php
// Show Contact
public function contact()
{
return View::make('pages.about.contact')->withInput([]);
}
// Process Contact
public function processContact()
{
$input = Input::all();
try
{
$this->contactForm->validate($input); // do validation here, dont need to use laracasts/valdation.
// Make sure the valiator throws an exception if it fails.
$input['message'] = nl2br($input['message']);
$data['ipaddr'] = Request::server('REMOTE_ADDR');
$data['header'] = Request::server('HTTP_USER_AGENT');
$data['form'] = 'Contact Form';
$this->mailer->send($data); // here is where you do logic and stuff, I send an email
Flash::success('Thank you for your message.');
return View::make('pages.about.contact')->withInput([]);
} catch (FormValidationException $e)
{
return Redirect::back()->withInput()->withErrors($e->getErrors());
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment