我是Laravel的新手,但設法使聯繫表單工作並在出現驗證錯誤時顯示。Laravel聯繫表確認警告框
但是我確實有一個問題,不知道如何在Laravel中處理它。發送郵件時(驗證規則通過)我想顯示一個警告框(引導程序樣式),說'謝謝,郵件已發送'。
CODE
public function postContact()
{
$formData = Input::all();
// input validator with its rules
$validator = Validator::make(
array(
'name' => $formData['name'],
'email' => $formData['email'],
'subject' => $formData['subject'],
'message' => $formData['message']
),
array(
'name' => 'required|min:3',
'email' => 'required|email',
'subject' => 'required|min:6',
'message' => 'required|min:5'
)
);
if ($validator -> passes()) {
// data is valid
Mail::send('emails.message', $formData, function($message) use ($formData) {
$message -> from($formData['email'], $formData['name']);
$message -> to('[email protected]', 'John Doe') -> subject($formData['subject']);
});
return View::make('contact');
} else {
// data is invalid
return Redirect::to('/contact') -> withErrors($validator);
}
}
我怎樣才能在Laravel 4實現這一目標?任何幫助將不勝感激。
謝謝。
漂亮,謝謝! – Ciwan 2014-11-03 09:07:04
不客氣! :-) – Cyruxx 2014-11-03 18:19:11