aledefreitas/lv-loadmorepagination
Composer 安装命令:
composer require aledefreitas/lv-loadmorepagination
包简介
Load More Pagination for Laravel. Allows to load an initial number of items and subsequent pages can load a different number of items
README 文档
README
A package that will give you access to a LoadMorePagination trait where you can paginate your model's results with an initial number of items and then a different number of items on subsequent pages.
This package does not implement any paginator interfaces or anything like that it simply returns a similar array to a paginator with the usual information such as last_page, current_page, data, etc.
Usage
To install this package do the following:
composer require vitorf7/lv-loadmorepagination
Once installed you can use this in two ways. Either by imporating this into your Eloquent Model or using it in your Controller or Repository, etc.
This package has an initial load of 9 items and subsequent load of 3.
In a Model:
<?php namespace App; use VitorF7\LoadMorePagination\LoadMorePagination; class Post extends Model { use LoadMorePagination; } // in a controller action or something you can use it like so Post::paginateLoadMore(); // Loads 9 on first page and 3 every page after that Post::paginateLoadMore(8, 4); // Loads 8 on first page and 4 every page after that Post::paginateLoadMore(4, 4); // Loads 4 on first page and 4 every page after that. However at this point you could just simply use Post::paginate(4). This package is better used when you need to load different amount of items from the first page // You can use it after you do an eager load of relationship too. At least simple loads for now as it has not been tested with something more complex Post::with('categories')->paginateLoadMore();
If you want to use it in a Controller, Repository, etc you need to pass 3 arguments.
- 1st Argument is the inital load of items
- 2nd Argument is the load of subsequent items
- 3rd Argument is the Model you are trying to paginate
Like so:
<?php namespace App\Http\Controllers; use App\Http\Controllers\Controller; use VitorF7\LoadMorePagination\LoadMorePagination; class PostsController extends Controller { use LoadMorePagination; public function index() { $posts = $this->paginatedLoadMore(9, 3, new Post); return view('posts.index', compact('posts')); } }
If you do not pass a model you will get a VitorF7\LoadMorePagination\ModelClassRequiredException
aledefreitas/lv-loadmorepagination 适用场景与选型建议
aledefreitas/lv-loadmorepagination 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 11 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「pagination」 「laravel」 「custom」 「load more」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 aledefreitas/lv-loadmorepagination 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 aledefreitas/lv-loadmorepagination 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 aledefreitas/lv-loadmorepagination 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Multiauth and custom grants for laravel passport
Custom SilverStripe tweaks to keep things tidy.
Extends basic Wordpress features.
Provides a Data Grid tables for your Symfony project.
This extension will allow you to set the default of product custom options for Magento 2
Normalize an index range from user input
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-11-13