Support the ongoing development of Laravel.io →
Eloquent Views
Last updated 2 years ago.
0

Search laravel 5 pagination you will find answer.

0

jimgwhit said:

Search laravel 5 pagination you will find answer.

The "Customizing The Paginator URI" solve my problem, but i don´t want customize url everytime and also i wan´t to have full URL included in my HTML, not just a part of it...

0

Full is there, you use relative to achieve this.

0

jimgwhit said:

Full is there, you use relative to achieve this.

I´m sorry but i don´t understand you now. Tha alternative which i use now is

{!! str_replace('/?', '?', $items->render()) !!}

However i think that there should be some better solution...

0

You did not show controller code, that would help.
Did you read. http://laravel.io/forum/11-13-2014-laravel-5-pagination

Last updated 9 years ago.
0

@miro4994

I also have problems with the base uri in pagination.

Are you using homestead or something like xampp?

0

Read
http://laravel.io/forum/11-13-2014-laravel-5-pagination. Showing your controller and view code would help.

0

I´m using xammp

Controller:

/**
 * Display the specified resource.
 *
 * @param  string  $slug
 * @return Response
 */
public function show($username, $slug, $section = null)
{

	try {
		$item = Item::bySlug($slug)->published()->firstOrFail();			
		switch ($section) {
			case 'comments':
				$data = $item->comments()->paginate(Item::$comments_per_page);
				break;
			case 'reviews':
				$data = $item->reviews()->paginate(Item::$comments_per_page);
				break;	
			default:
				$section = 'item';
				$data = null;
				break;			
		}

		return view('items.show', ['item' => $item, 'data' => $data, 'section' => $section]);
			
	} catch (ModelNotFoundException $e) {
		return Response::make('Not Found', 404);	
	}		
		
}

Code in view:


{!! $data->render() !!}

Current fix:


{!! str_replace('/?', '?', $data->render()) !!}

And yes, i readed the documentation already. I use it always. However this is some kind of problem which i can´t figure out how to fix it.

Last updated 9 years ago.
0

Did you read the whole thing, like the part about

Pagination::makeLengthAware .......

I promise you paginate like in the post I refered you to and all will work. No other way.
Also, check your vars, does a var have a / at the end?

Last updated 9 years ago.
0

@miro4994

This must be xampp related. I have to render pagination like this:

$object->setPath('')->appends(Input::query())->render()

If I don't use setPath(''), the trailing slash appears.

I call it from a macro, so I never have to manually specify ->setPath('').

0

micaweb said:

@miro4994

This must be xampp related. I have to render pagination like this:

$object->setPath('')->appends(Input::query())->render()

If I don't use setPath(''), the trailing slash appears.

I call it from a macro, so I never have to manually specify ->setPath('')

The slash is still here, however if you use homestead instead of ex. xampp its going to work correctly even with the slash before the query string.

0

@miro4994 Homestead is yet another development environment.

But in my production server the pagination links are invalid due to the trailing slash. I know there is a workaround (calling setPath()).

@micaweb But is there any better solution?

Last updated 9 years ago.
0

@astroanu : It is not really a solution because it is not a HTTP error. The answer status will be 200 and not 404 here. And I would like that the answer will be 404 and not 200.


Lily lara

Last updated 9 years ago.
0

Thanks for this fixing. great help full .thanks

0

Thanks for this fixing,too.Thanks

0

Sign in to participate in this thread!

Eventy

Your banner here too?

miro4994 miro4994 Joined 9 Feb 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.