thomhurks/laravel-collection-extensions 问题修复 & 功能扩展

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

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

thomhurks/laravel-collection-extensions

Composer 安装命令:

composer require thomhurks/laravel-collection-extensions

包简介

Extensions for Laravel's Collection class. Notably groupByMultiple for grouping collections on multiple fields instead of just one.

README 文档

README

Extensions for Laravel's Collection class. Notably groupByMultiple for grouping collections on multiple fields instead of just one.

Example:

A B C D
foo bar baz thud
foo garply corge plugh
foo bar corge thud
foo bar corge waldo
qux garply xyzzy fred
qux grault garply quuz

By calling myCollection->groupBy(['A', 'B', 'C', 'D']) the result would become:

  • foo
    • bar
      • baz
        • thud [foo, bar, baz, thud]
      • corge
        • thud [foo, bar, corge, thud]
        • waldo [foo, bar, corge, waldo]
    • garply
      • corge
        • plugh [foo, garply, corge, plugh]
  • qux
    • garply
      • xyzzy
        • fred [quz, garply, xyzzy, fred]
    • grault
      • garply
        • quuz [qux, grault, garply, quuz]

Cross compatibility The groupByMultiple function is somewhat compatible with Laravel's original groupBy in that it functions in the same way if you pass as first argument something that is not an array, so just like groupBy you can call it with a string or a closure. The function just puts the first argument in an array if it isn't one. If you try to pass a callable as an array, so ["Foo", "Bar"] where Foo::Bar() is a valid method, then of course the groupByMultiple function will just attempt to group on the key "Foo" first and "Bar" second; this is the main incompatibility with groupBy(). Of course you can pass an array with a callable in it, so [["Foo", "Bar"]] or [["Foo", "Bar"], "Baz"] would work just fine. For people already using groupBy, this function will be very easy to switch to.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-03-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固