在Laravel中访问表单提交的路线

时间:2016-02-02 11:30:12

标签: php laravel

我想在我的视图中访问pages.trashmultiple这样的一条路线。但它的投掷误差为Route [pages.trashmultiple] not defined.。以下是我的观点:

    {!!Form::open([
                'method' => 'put',
                'route' => 'pages.trashmultiple'
    ])!!}

<th class="table-checkbox">
        <input type="checkbox" class="group-checkable" data-set="#sample_3 .checkboxes"/>
</th>

{!!Form::close()!!}

这就是我的控制器的样子:

 public function trashmultiple(Request $request){
        //return "trash multiple page";
        return Input::all();
  }

这就是我的路线的样子:

Route::group(['middleware' => ['web']], function () {

    Route::get('pages/trash', 'PagesController@trashpage');

    Route::get('pages/movetotrash/{id}', 'PagesController@movetotrash');

    Route::get('pages/restore/{id}', 'PagesController@restore');

    Route::get('pages/trashmultiple', 'PagesController@trashmultiple'); //this is not working

    Route::resource('pages', 'PagesController');

});

当我加载我的网址http://localhost:8888/laravelCRM/public/pages时,它会向我显示以下错误:

ErrorException in UrlGenerator.php line 307:
Route [pages.trashmultiple] not defined. (View: /Applications/MAMP/htdocs/laravelCRM/resources/views/pages/pages.blade.php)

我想知道为什么我已经定义它时无法访问pages.trashmultiple

有什么方法可以通过pages.trashmultiple访问它吗?

谢谢! (提前)

2 个答案:

答案 0 :(得分:0)

按照您的路线选择:

Route::get('pages/trashmultiple', 'PagesController@trashmultiple');

Route::get('pages/trashmultiple', [
    'as' => 'pages.trashmultiple', 'uses' => 'PagesController@trashmultiple'
]);

答案 1 :(得分:0)

更改您的路线,使其成为:

 Route::get('pages/trashmultiple', 
    ['as'=>'pages.trashmultiple',
     'uses'=>'PagesController@trashmultiple']);