我正在Laravel 5中创建联系表单。联系表单在主页上,当用户填写表单然后单击提交按钮时,laravel使用mandrill发送电子邮件并刷新页面。该代码在我的本地环境中完美运行。但是,当用户点击提交按钮时,在数字海洋小滴上,触发了domain.com/contact路由,我只能看到一个空白页面。
这是我的控制器
<?php namespace App\Http\Controllers;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Http\Requests\ContactFormRequest;
use Illuminate\Http\Request;
class ContactController extends Controller {
public function create() {
return view('forms.contact');
}
public function store(ContactFormRequest $request) {
\Mail::send('emails.contact',
array(
'name' => $request->get('name'),
'email' => $request->get('email'),
'user_message' => $request->get('message')
), function($message)
{
$message->from('info@pbl-landing.com');
$message->to('muhammetergenc@gmail.com', 'Admin')->subject('Contact Request');
});
return \Redirect::route('index')->with('message', 'Thanks for contacting us!');
}
}
这是我的routes.php文件
Route::get('/',
['as'=>'index', 'uses'=>'WelcomeController@index']);
Route::get('home', 'HomeController@index');
Route::controllers([
'auth' => 'Auth\AuthController',
'password' => 'Auth\PasswordController',
]);
Route::get('contact',
['as' => 'contact', 'uses' => 'ContactController@create']);
Route::post('contact',
['as' => 'contact_store', 'uses' => 'ContactController@store']);