I am coding a contact search system by laravel, and use pagination to pagine search results.So when I post a form to url like "search/contact", the system works and display right results and right pagination links in page.But then, when I click the page links with a url like "search/contact/?page=7", a GET request is sent by browser, consequently I lose my search data in this request.
I imagine your original post requests works fine but once you get the result set in other words the listing of results then it becomes get requests not a POST request. See. http://laravel.io/forum/11-13-2014-laravel-5-pagination This is 5.0, 5.1 will be different but you can get some ideas from this.
If you want to post using pagination you would have to use something like a session variable to store which page you are on and pass that each time. But passing that in the query string is standard practice even large sites like FedEx do it that way. You should study some basic crud examples.
@jlrdw I think maybe I can use GET request instead of POST request to achieve query function, and then use $object->appends(Input::query())->render() to pass that in pagination links.
If you want to post using pagination you would have to use something like a session variable to store which page you are on and pass that each time. But passing that in the query string is standard practice even large sites like FedEx do it that way. You should study some basic crud examples.
Look at this very forum you are on, now when I edit or add a thread, look at the button, it says post your reply. So that is a post. Now when you are paging through the threads those would be get request. Likewise when you click on a thread it opens for viewing or editing. Normally in a table you would have a edit button but here you simply click on the thread.
Same difference normally the edit button or link is sent with get request. But after a successful update it is normally a POST request.
Something like this you send your post request to method in controller. Handle the request and pass the data to a different controller method to display the results paginates the will handle subsequent get requests.
At first in your route set resource method, then you can pass your key in your blade page thorough controller. Then in your controller you can use append method in your pagination link. Below i am giving you some example:
Route::resource( '/search', 'BillingController@find' );
Controller:
->with( 'region', $region ) // key for you search