A few extensions to the Laravel Collection and Arr.

0.1.3 2022-10-14 10:54 UTC

This package is auto-updated.

Last update: 2024-02-20 12:17:59 UTC


A few extensions to the Laravel Collection and Arr.


composer require konsulting/laravel-extend-collections

Using Laravel

If you are using Laravel 5.5, this package will auto-register the service provider. However, if you have chosen not to auto-register, or are using an earlier version, add the CollectionsServiceProvider to your config/app.php.

'providers' => [
    // Other service providers...


Not using Laravel

There is a simple namespaced helper function to assist with extending Collection and Arr.

// Inside your application code, run:


Arr Extensions

  • fromDot - convert an array where the keys are dot-notation indexed to a nested array

Collection extensions

  • dropEmpty - drop items whose values are empty()
  • deep - apply a function recursively through a collection, and through arrays/collections within it
  • dotGet - retrieve an item using dot-notation
  • dotSet - set an item using dot-notation
  • dotHas - check if an item exists using dot-notation
  • dot - convert a nested collection to dot-notation indexed collection
  • fromDot - convert a dot-notation indexed collection to a nested collection


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


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


We use PHPUnit

Run tests using PHPUnit: vendor/bin/phpunit