konsulting/laravel-sorting 问题修复 & 功能扩展

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

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

konsulting/laravel-sorting

最新稳定版本:0.1.7

Composer 安装命令:

composer require konsulting/laravel-sorting

包简介

A sorting package for laravel

README 文档

README

A set of utilities for sorting models in Laravel.

Installation

Install using composer: composer require konsulting/laravel-sorting

Usage

Sorting

  • Add the Konsulting\Laravel\Sorting\Sortable trait to your model.
  • Set up the configuration for the model by adding the $sortableSettings property providing the allowed sortable fields and a default sort order.
protected static $sortableSettings = [
    'sortable' => ['name', 'created_at', 'updated_at'],
    'defaultSort' => '+name',
];
  • In your view where you’d like to add a sortable link, include the following (example for a Post model):
{{ App\Post::sortableLink('name', 'Name') }}
  • When you want retrive a sorted collection of models, use the sort() method.
App\Post::sort()->paginate();
// The sort method will extract the sort variable from the request, unless you pass them through (e.g. if you store in the session).

Prioritise

  • Add the Konsulting\Laravel\Sorting\Prioritise trait to your model.

  • Ensure your model has a column for 'priority'. By default, this is called 'priority' but can be overriden if needed by overriding the determinePriorityColumnName() method in the model.

  • Use the prioritise scope to sort the retrieved results by priority.

Security

If you find any security issues, or have any concerns, please email keoghan@klever.co.uk, rather than using the issue tracker.

Contributing

Contributions are welcome and will be fully credited. We will accept contributions by Pull Request.

Please:

  • Use the PSR-2 Coding Standard
  • Add tests, if you’re not sure how, please ask.
  • Document changes in behaviour, including readme.md.

Testing

We use PHPUnit.

Run tests using PHPUnit: vendor/bin/phpunit

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

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