Package Data | |
---|---|
Maintainer Username: | Agel Nash |
Maintainer Contact: | agel_nash@xaker.ru (Agel_Nash) |
Package Create Date: | 2013-11-11 |
Package Last Update: | 2017-05-03 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-19 03:07:17 |
Package Statistics | |
---|---|
Total Downloads: | 824 |
Monthly Downloads: | 2 |
Daily Downloads: | 0 |
Total Stars: | 6 |
Total Watchers: | 1 |
Total Forks: | 2 |
Total Open Issues: | 0 |
This extension pack pagination laravel. With it, you can prevent the opening of blank pages. For example, in your pagination has only 10 pages, but the user has requested page with number 101. With this extension pack, user redirected to the last (10) or first page... or send 404 error.
And most importantly, paginator now contains no reference to the first page with the GET variable.
http://example.com/news?page=1
http://example.com/news?page=2
http://example.com/news?page=3
...
etc.
http://example.com/news
http://example.com/news?page=2
http://example.com/news?page=3
...
etc.
composer require agelxnash/seopagination:5.2.*@dev
Once SEOPagination is installed you need to register the service provider with the application. Open up config/app.php
and replace Illuminate\Pagination\PaginationServiceProvider
the providers key to
AgelxNash\SEOPagination\PaginationServiceProvider::class
You will want to run the following command to publish the config to your application, otherwise it will be overwritten when the package is updated.
php artisan vendor:publish --provider="AgelxNash\SEOPagination\PaginationServiceProvider"
Now you can edit the file config/seo-pagination.php
Any response status code. For example - 307 (default) or 301
Add the trait to your model
use Illuminate\Database\Eloquent\Model;
Class Post extends Model{
use \AgelxNash\SEOPagination\Eloquent\ReplaceBuilder
}
After the call paginate() method, you can check data variable in the method checkPaginate()
. The result will be object \Illuminate\Http\RedirectResponse
or true
Look at the example method of a controller with check pagination:
public function example()
{
$posts = Post::->orderBy('created_at', 'DESC')->paginate(10);
if(($out = $posts->checkPaginate()) === true){
$out = View::make('index', array('data'=> $posts));
}
return $out;
}