Support the ongoing development of Laravel.io →
Configuration Laravel.io Packages
Last updated 2 years ago.
0

1. Pagination

'pagination' => 'pagination.custom'

Create a file custom.php in views/pagination/ and copy this in (modify as needed):

<?php
	$presenter = new Illuminate\Pagination\BootstrapPresenter($paginator);
?>

<?php if ($paginator->getLastPage() > 1): ?>
	<div class="pagination">
		<ul>
			<?php echo $presenter->render(); ?>
		</ul>
	</div>
<?php endif; ?>

2. Presenter

Save the ZurbPresenter.php in app/{your_project_name_or_something}/Presenters/ and paste code:

<?php 

namespace {your_project_name_or_something}\Presenters;
                            
class ZurbPresenter extends \Illuminate\Pagination\Presenter {

    public function getActivePageWrapper($text)
    {
        return '<li class="current"><a href="">'.$text.'</a></li>';
    }

    public function getDisabledTextWrapper($text)
    {
        return '<li class="unavailable">'.$text.'</li>';
    }

    public function getPageLinkWrapper($url, $page, $rel = null)
    {
        return '<li><a href="'.$url.'">'.$page.'</a></li>';
    }
}

I added the namespace (modify it) and $rel = null because it's throwing an error without it.

3. Composer

Modify composer.json:

"autoload": {
	"classmap": [
		"app/commands",
		"app/controllers",
		"app/models",
		"app/database/migrations",
		"app/database/seeds",
		"app/tests/TestCase.php"
	],
	"psr-4": {
		"{your_project_name_or_something}\\": "app/"
	}
},

After that open command line and cd to project dir and run "composer dump-autoload -o"

4. The view

{{ with(new {your_project_name_or_something}\Presenters\ZurbPresenter($models))->render() }}

I hope I haven't missed anything.

Last updated 2 years ago.
0

Great. Thanks man. This totally works. But one more thing - When it render the pagination it look like this ->

« 1 2 »

How can I remove the '« »' symbols?

Last updated 2 years ago.
0

To remove the unclickable one use "return null;" on getDisabledTextWrapper. I haven't figured out the ones that are links.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

alf13 alf13 Joined 23 Jul 2014

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.