如何在Laravel 4.2中使用querystring重定向命名路由 [英] How to redirect a named route with querystring in Laravel 4.2
问题描述
我是Laravel框架的新手.我正在使用4.2我的问题是我有分页功能 在manageemployeeee页面中,我为manageemployeeee页面创建了一条路线.
I am new to Laravel framework. I am using 4.2 my question is i had a pagination functionality in a manageemployee page, I have created a route for manageemployee page.
Route::get('/usercp/manageemployee',array('uses' =>'ManageEmployeeController@getManageCompanyEmployee','as' =>'getManageCompanyEmployee'));
在此页面中,我有分页,如果用户在第三页,则他要删除一条记录.
In this page i have pagination , if user was in third page, he want to delete one record.
现在页面看起来像/usercp/manageemployee?page = 3 .删除该页面中的特定记录后,我需要将用户重定向到同一页面.
now the page looks like /usercp/manageemployee?page=3 After deleting a particular record in that page i need to redirect user to the same page.
我的重定向代码如下
return Redirect::route('getManageCompanyEmployee')->with('success','Record deleted successfully');
但是使用上面的代码,用户会像/usercp/manageemployee这样进入首页.但是重定向后,用户需要位于第3页/usercp/manageemployee?page = 3.
But with the above code user comes to the first page like /usercp/manageemployee. But after redirecting user needs to be in 3rd page /usercp/manageemployee?page=3.
如何做到这一点?
推荐答案
所有传递给您的非路由参数的路由都会自动成为路由查询:
Everything you pass to your route that is not a route parameters, becomes a route query automatically:
return Redirect::route('getManageCompanyEmployee', ['page' => 3])
->with('success','Record deleted successfully');
但是您也可以这样做:
return Redirect::refresh()->with('success','Record deleted successfully');
将用户保持在同一页面上.
Keeping the user in the very same page.
或
return Redirect::back()->with('success','Record deleted successfully');
取决于您的用例.
这篇关于如何在Laravel 4.2中使用querystring重定向命名路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!