1

I am using laravel 5.1 pagination. But its not working. I guess the problem is accessing query string parameter.

routes.php

Route::get('blogs', 'front\FrontController@blog');

Controller

public function blog(Request $request)
{
    print_r($request->fullUrl());
    die;
    $blogs=Blog::with('User')->where('flag','!=','0')->paginate(2);
    return view('front.pages.blog_list',['blogs'=>$blogs]);
}

For url http://localhost/myproject/blogs?page=2

Result : http://localhost/myproject/blogs?blogs. Where it should be ?page=2 instead of ?blogs. I have also noticed that query string parameters are not also working in others page. Any idea? Thanks in advance.

3
  • Why do you need request? Why do you call die? Commented Jun 11, 2016 at 12:22
  • for debug purpose. I wanted to sure that if page works or not @DevinGray Commented Jun 12, 2016 at 4:09
  • almost sounds like a web server misconfiguration for how its handling the query string? Commented Jun 13, 2016 at 8:02

2 Answers 2

1

use ->appends(\Input::except('page'))

return view('front.pages.blog_list',[ 'blogs'=>$blogs->appends(\Input::except('page')) ]);

Sign up to request clarification or add additional context in comments.

9 Comments

Thanks @Ravisha Hesh. But It's not working. I dont know why I cant access query string :( parameters...
did you see your params when you add dd($request->all()); into your method?
Yes @Ravisha Hesh. It does not show page. just Array ( [blogs] => ) .
leave dd() as I mentioned on previous comment and go to localhost/myproject/blogs?page=2 manually by clicking on this link
You can use appends($request->all()) in laravel to include additional params in pagination, pagination object contains links to next and prev pages, use those for navigation
|
1

The reason was .htaccess file.

1 Comment

What should be in .htaccess file?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.