To achieve this and very simple
Layout:
{{ Form:: open(array('action' => 'ContactController@getContactUsForm')) }}
<ul class="errors">
@foreach($errors->all('<li>:message</li>') as $message)
@endforeach
</ul>
<div class="form-group">
{{ Form:: textarea ('message', '', array('placeholder' => 'Message', 'class' => 'form-control', 'id' => 'message', 'rows' => '4' )) }}
</div>
</div>
<div class="modal-footer">
{{ Form::submit('Submit', array('class' => 'btn btn-primary')) }}
{{ Form:: close() }}
Add the following route
Route::post('contact_request','ContactController@getContactUsForm
And the following controller
public function getContactUsForm(){
//Get all the data and store it inside Store Variable
$data = Input::all();
//Validation rules
$rules = array (
//'first_name' => 'required', uncomment if you want to grab this field
//'email' => 'required|email', uncomment if you want to grab this field
'message' => 'required|min:5'
);
//Validate data
$validator = Validator::make ($data, $rules);
//If everything is correct than run passes.
if ($validator -> passes()){
Mail::send('emails.feedback', $data, function($message) use ($data)
{
//$message->from($data['email'] , $data['first_name']); uncomment if using first name and email fields
$message->from('[email protected]', 'feedback contact form');
//email 'To' field: cahnge this to emails that you want to be notified.
$message->to('[email protected]', 'John')->cc('[email protected]')->subject('feedback form submit');
});
// Redirect to page
return Redirect::route('home')
->with('message', 'Your message has been sent. Thank You!');
//return View::make('contact');
}else{
//return contact form with errors
return Redirect::route('home')
->with('error', 'Feedback must contain more than 5 characters. Try Again.');
}
}
}
link