Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
470 views
in Technique[技术] by (71.8m points)

routing - How to redirect a named route with querystring in Laravel 4.2

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.

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.

My Redirect code as follows

return Redirect::route('getManageCompanyEmployee')->with('success','Record deleted successfully');

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.

How to acheive this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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');

But you could also do:

return Redirect::refresh()->with('success','Record deleted successfully');

Keeping the user in the very same page.

Or

return Redirect::back()->with('success','Record deleted successfully');

Depending on your use case.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...