laravel 4,NotFoundHttpException

时间:2014-08-01 12:03:55

标签: laravel-4

我在提交此表单时遇到问题,它会产生NotFoundHttpException

{{Form::open(array('parsley-validate'=>'','url'=>url('dashboard/send_message')))}}

这是表单应在仪表板文件夹

中的dashHome.php中执行的功能
public function postSendMessage()
{
    $validator = Validator::make(Input::all(), array(
        'studentId' => 'required|exists:student,id',
        'content' => 'required',
        ));

    if ($validator->fails())
        return Redirect::to('dashboard')->withErrors($validator);

    $user = Auth::user();

    $user->decrement('sms_credit');

    return Redirect::to('dashboard')->with('messageSent',1);
}

这是route.php中的路线

Route::group(array('prefix' => 'dashboard','before'=>'auth'), function() {

Route::get('/', 'dashHome@index');

});

1 个答案:

答案 0 :(得分:0)

您需要在dashboard/send_message文件中为网址routes.php定义路线,如下所示:

Route::group(array('prefix' => 'dashboard','before'=>'auth'), function() 
{
    Route::get('/', 'dashHome@index');
    Route::post('send_message', 'dashHome@postSendMessage');
});