Skip to content

Commit

Permalink
updated readme and changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexVanderbist committed Aug 4, 2017
1 parent 4ec3071 commit 692b840
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

All notable changes to `laravel-collection-macros` will be documented in this file

## 2.5.0 - 2017-08-03
- Added customization options for `sectionBy`

## 2.4.0 - 2017-08-02
- Added: `sectionBy`

Expand Down
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,43 @@ $collection->sectionBy('module');
// ];
```

You can also pass the `$sectionKey`, `$itemsKey` and `$preserveKeys` parameters to customize the sectioned output:

```php
$collection = collect([
'lesson1' => ['name' => 'Lesson 1', 'module' => 'Basics'],
'lesson2' => ['name' => 'Lesson 2', 'module' => 'Basics'],
'lesson3' => ['name' => 'Lesson 3', 'module' => 'Advanced'],
'lesson4' => ['name' => 'Lesson 4', 'module' => 'Advanced'],
'lesson5' => ['name' => 'Lesson 5', 'module' => 'Basics'],
]);

$collection->sectionBy('module', 'moduleName', 'lessons', true);

// [
// [
// 'moduleName' => 'Basics',
// 'lessons' => [
// 'lesson1' => ['name' => 'Lesson 1', 'module' => 'Basics'],
// 'lesson2' => ['name' => 'Lesson 2', 'module' => 'Basics'],
// ],
// ],
// [
// 'moduleName' => 'Advanced',
// 'lessons' => [
// 'lesson3' => ['name' => 'Lesson 3', 'module' => 'Advanced'],
// 'lesson4' => ['name' => 'Lesson 4', 'module' => 'Advanced'],
// ],
// ],
// [
// 'moduleName' => 'Basics',
// 'lessons' => [
// 'lesson5' => ['name' => 'Lesson 5', 'module' => 'Basics'],
// ],
// ],
// ];
```

### `after`

Get the next item from the collection.
Expand Down

0 comments on commit 692b840

Please sign in to comment.