agelxnash/seopagination 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

agelxnash/seopagination

Composer 安装命令:

composer require agelxnash/seopagination

包简介

Laravel SEO Pagination

README 文档

README

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.

Old

http://example.com/news?page=1
http://example.com/news?page=2
http://example.com/news?page=3
...
etc.

New

http://example.com/news
http://example.com/news?page=2
http://example.com/news?page=3
...
etc.

Installation

Step 1

composer require agelxnash/seopagination:5.2.*@dev

Step 2

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

Configuration

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

action_on_error

  • first (Send redirect to first pagination page with error_status response status code)
  • out (Send redirect to end pagination page with error_status response status code)
  • abort (Return 404 error. Not use error_status)

error_status

Any response status code. For example - 307 (default) or 301

Usage

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;
}

统计信息

  • 总下载量: 1.03k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-11-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固