PHPackages                             sebastiaanluca/laravel-helpers - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. sebastiaanluca/laravel-helpers

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

sebastiaanluca/laravel-helpers
==============================

An extensive set of Laravel framework helper functions and collection macros.

6.0.0(5y ago)42754.3k↓27.3%264MITPHPPHP ^7.3

Since Jan 9Pushed 5y ago11 watchersCompare

[ Source](https://github.com/sebastiaanluca/laravel-helpers)[ Packagist](https://packagist.org/packages/sebastiaanluca/laravel-helpers)[ Docs](https://github.com/sebastiaanluca/laravel-helpers)[ RSS](/packages/sebastiaanluca-laravel-helpers/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (5)Versions (24)Used By (4)

[![](https://raw.githubusercontent.com/sebastiaanluca/laravel-helpers/develop/logo.png "Laravel Helpers")](https://raw.githubusercontent.com/sebastiaanluca/laravel-helpers/develop/logo.png)

[![Latest stable release](https://camo.githubusercontent.com/358fa40c0988d6fc67a669eafc5004f42f55e23db3906539353d7cbb8a311551/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7365626173746961616e6c7563612f6c61726176656c2d68656c706572732e7376673f6c6162656c3d737461626c65)](https://packagist.org/packages/sebastiaanluca/laravel-helpers)[![Software license](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](LICENSE.md)[![Build status](https://camo.githubusercontent.com/e909454fe9c783523823dcaf966bf98cefd4f74e1df3295953310526e6745b1b/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7365626173746961616e6c7563612f6c61726176656c2d68656c706572732f6d61737465722e737667)](https://travis-ci.org/sebastiaanluca/laravel-helpers)[![Total downloads](https://camo.githubusercontent.com/2206fce1bd8e4b52b8553ba44995bf6d0289cca2653a027622f544f805e2de7e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7365626173746961616e6c7563612f6c61726176656c2d68656c706572732e737667)](https://packagist.org/packages/sebastiaanluca/laravel-helpers)[![Total downloads](https://camo.githubusercontent.com/38d1c3e1bb46e86509bc67b6cc5932091263793d4160a4c8cbf6cf9b8dc938b4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f7365626173746961616e6c7563612f6c61726176656c2d68656c706572732e7376673f636f6c6f723d627269676874677265656e)](https://packagist.org/packages/sebastiaanluca/laravel-helpers)

[![Read my blog](https://camo.githubusercontent.com/0760b582e22202bd412feb64f5f87b6459f64a0b8ea5fdd24cbadf87df736177/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c696e6b2d626c6f672d6c69676874677265792e737667)](https://blog.sebastiaanluca.com)[![View my other packages and projects](https://camo.githubusercontent.com/5ce3a83ee0ec2b4ae47a99f67347c1d8e78582757eca80fe31c98e5bd0e2185a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c696e6b2d6f746865725f7061636b616765732d6c69676874677265792e737667)](https://packagist.org/packages/sebastiaanluca)[![Follow @sebastiaanluca on Twitter](https://camo.githubusercontent.com/bde346ed8efc8b2458386b36256c64e3fe010276f449b80fe4f663c4c8bbd83e/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f666f6c6c6f772f7365626173746961616e6c7563612e7376673f7374796c653d736f6369616c)](https://twitter.com/sebastiaanluca)[![Share this package on Twitter](https://camo.githubusercontent.com/cb820a0ecc9645168e33b03925d7f14691262ddbaeaf66a0a91697803d0cba2d/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f75726c2f687474702f736869656c64732e696f2e7376673f7374796c653d736f6369616c)](https://twitter.com/home?status=https://twitter.com/intent/tweet?text=Check%20out%20this%20extensive%20set%20of%20Laravel%20framework%20helper%20functions%20and%20collection%20macros!%20Via%20@sebastiaanluca%20https://github.com/sebastiaanluca/laravel-helpers)

**An extensive set of Laravel framework helper functions and collection macros.**

Table of contents
-----------------

[](#table-of-contents)

- [Requirements](#requirements)
- [How to install](#how-to-install)
- [Upgrading from 1.x](#upgrading-from-1x)
- [Framework helper functions](#framework-helper-functions)
    - [locale](#locale)
    - [is\_guest](#is_guest)
    - [is\_logged\_in](#is_logged_in)
    - [me](#me)
    - [user](#user)
- [Collection macros](#collection-macros)
    - [Carbonize](#carbonize)
    - [Between](#between)
    - [transformKeys](#transformkeys)
    - [transpose](#transpose)
    - [transposeWithKeys](#transposewithkeys)
    - [d](#d)
    - [ddd](#ddd)
- [License](#license)
- [Change log](#change-log)
- [Testing](#testing)
- [Contributing](#contributing)
- [Security](#security)
- [Credits](#credits)
- [About](#about)

Requirements
------------

[](#requirements)

- PHP 7.3 or higher
- Laravel 7.0 or higher

How to install
--------------

[](#how-to-install)

Just add the package to your project using Composer and Laravel will auto-discover it:

```
composer require sebastiaanluca/laravel-helpers
```

If you want to use the collection debug macros, install the [kint-php/kint](https://github.com/raveren/kint) package as a dev dependency:

```
composer require kint-php/kint --dev
```

Upgrading from 1.x
------------------

[](#upgrading-from-1x)

All essential generic PHP helpers have been extracted to their own [sebastiaanluca/php-helpers](https://github.com/sebastiaanluca/php-helpers) package and some other helpers have been removed in anticipation of their own package. In effect and from now on, Laravel Helpers will only contain helpers for the Laravel framework.

[See the changelog](CHANGELOG.md#200-2018-07-22) for more information.

Framework helper functions
--------------------------

[](#framework-helper-functions)

### locale

[](#locale)

Get the active app locale or the fallback locale if it's missing or not set.

```
locale();

// "en"
```

### is\_guest

[](#is_guest)

Determine if the current user is a guest.

The opposite of [is\_logged\_in](#is_logged_in).

```
// When not authenticated
is_guest();

// true

// When authenticated as a user
is_guest();

// false
```

### is\_logged\_in

[](#is_logged_in)

Determine if the current user is authenticated.

The opposite of [is\_guest](#is_guest).

```
// When not authenticated
is_logged_in();

// false

// When authenticated as a user
is_logged_in();

// true
```

### user

[](#user)

Get the currently authenticated user (if there is one).

When logged in, returns your user model or object that implements `\Illuminate\Contracts\Auth\Authenticatable`.

```
// When not authenticated
user();

// null

// When authenticated as a user
user();

// Illuminate\Foundation\Auth\User {}
```

### me

[](#me)

Get the currently authenticated user (if there is one).

When logged in, returns your user model or object that implements `\Illuminate\Contracts\Auth\Authenticatable`.

An alternative for [user](#user).

```
// When not authenticated
me();

// null

// When authenticated as a user
me();

// Illuminate\Foundation\Auth\User {}
```

Collection macros
-----------------

[](#collection-macros)

### carbonize

[](#carbonize)

Create Carbon instances from items in a collection.

```
collect([
    'yesterday',
    'tomorrow',
    '2017-07-01',
])->carbonize();

/*
Illuminate\Support\Collection {
    all: [
        Carbon\Carbon {
            "date": "2017-07-09 00:00:00.000000",
            "timezone_type": 3,
            "timezone": "UTC",
        },
        Carbon\Carbon {
            "date": "2017-07-11 00:00:00.000000",
            "timezone_type": 3,
            "timezone": "UTC",
        },
        Carbon\Carbon {
            "date": "2017-07-01 00:00:00.000000",
            "timezone_type": 3,
            "timezone": "UTC",
        },
    ],
}
*/
```

### between

[](#between)

Reduce each collection item to the value found between a given start and end string.

The second parameter is optional and falls back to the start string if `null`.

```
collect([
    '"value1"',
    '"value2"',
    '"value3"',
])->between('"', '"');

/*
Illuminate\Support\Collection {
    all: [
        "value1",
        "value2",
        "value3",
    ],
}
*/
```

### transformKeys

[](#transformkeys)

Perform an operation on the collection's keys.

The callable operation can either be a globally available method or a closure.

```
collect([
    'a' => 'value',
    'b' => 'value',
    'c' => 'value',
])->transformKeys('strtoupper');

/*
Illuminate\Support\Collection {
    all: [
        "A" => "value",
        "B" => "value",
        "C" => "value",
    ],
}
*/
```

```
collect([
    'a' => 'value',
    'b' => 'value',
    'c' => 'value',
])->transformKeys(function (string $key) {
    return 'prefix-' . $key;
});

/*
Illuminate\Support\Collection {
    all: [
        "prefix-a" => "value",
        "prefix-b" => "value",
        "prefix-c" => "value",
    ],
}
*/
```

### transpose

[](#transpose)

Transpose (flip) a collection matrix (array of arrays) so its columns become rows and its rows become columns.

```
collect([
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9],
])->transpose();

/*
Illuminate\Support\Collection {
    all: [
        [1, 4, 7],
        [2, 5, 8],
        [3, 6, 9],
    ],
}
*/
```

### transposeWithKeys

[](#transposewithkeys)

Flip a collection of rows and values per column so its columns become rows and its rows become columns.

Before:

idnameA1JamesB2JoeC3JonasAfter:

ABCid123nameJamesJoeJonasHow to use:

```
collect([
    'A' => [
        'id' => 1,
        'name' => 'James',
    ],
    'B' => [
        'id' => 2,
        'name' => 'Joe',
    ],
    'C' => [
        'id' => 3,
        'name' => 'Jonas',
    ],
])->transposeWithKeys();

/*
Illuminate\Support\Collection {
    all: [
        "id" => [
            "A" => 1,
            "B" => 2,
            "C" => 3,
        ],
        "name" => [
            "A" => "James",
            "B" => "Joe",
            "C" => "Jonas",
        ],
    ],
}
*/
```

You can also pass some row header names if you don't want them to be automatically guessed. You'd then call the macro with `transposeWithKeys(['myID', 'row2'])` and the resulting rows would be `myID` and `row2` instead of `id` and `name` respectively.

### d

[](#d)

Display structured debug information on the collection using Kint. Can be called multiple times during a collection's method chain and outputs debug information at each point of use. Continues script execution afterwards.

Explicitly requires the [kint-php/kint](https://github.com/raveren/kint) package.

```
collect([
    'id' => 6,
    'name' => 'Sebastiaan',
])
->d()
->put('role', 'author')
->d();
```

### ddd

[](#ddd)

Display structured debug information on the collection using Kint. Halts script execution afterwards, so it can only be called once during a collection's method chain.

Explicitly requires the [kint-php/kint](https://github.com/raveren/kint) package.

```
collect([
    'id' => 6,
    'name' => 'Sebastiaan',
])
->d()
->put('role', 'author')
->ddd();
```

License
-------

[](#license)

This package operates under the MIT License (MIT). Please see [LICENSE](LICENSE.md) for more information.

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
composer install
composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE OF CONDUCT](CODE_OF_CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Sebastiaan Luca](https://github.com/sebastiaanluca)
- Logo by [Vitor Caneco](https://github.com/caneco)
- [All Contributors](../../contributors)

About
-----

[](#about)

My name is Sebastiaan and I'm a freelance Laravel developer specializing in building custom Laravel applications. Check out my [portfolio](https://www.sebastiaanluca.com) for more information, [my blog](https://blog.sebastiaanluca.com) for the latest tips and tricks, and my other [packages](https://packagist.org/packages/sebastiaanluca) to kick-start your next project.

Have a project that could use some guidance? Send me an e-mail at !

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity48

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 99.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~65 days

Recently: every ~118 days

Total

22

Last Release

2032d ago

Major Versions

1.0.3 → 2.0.02018-07-22

2.1.0 → 3.0.02019-02-27

3.0.3 → 4.0.02019-08-13

4.0.0 → 5.0.02020-04-24

5.0.0 → 6.0.02020-10-19

PHP version history (4 changes)0.1.0PHP ^7.0

0.5.3PHP ^7

2.0.0PHP ^7.2

5.0.0PHP ^7.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/711940?v=4)[Sebastiaan Luca](/maintainers/sebastiaanluca)[@sebastiaanluca](https://github.com/sebastiaanluca)

---

Top Contributors

[![sebastiaanluca](https://avatars.githubusercontent.com/u/711940?v=4)](https://github.com/sebastiaanluca "sebastiaanluca (268 commits)")[![n7olkachev](https://avatars.githubusercontent.com/u/3993345?v=4)](https://github.com/n7olkachev "n7olkachev (2 commits)")

---

Tags

arraycollectionshelperslaravelmacrosphplaravelhelperscollectionsmacros

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sebastiaanluca-laravel-helpers/health.svg)

```
[![Health](https://phpackages.com/badges/sebastiaanluca-laravel-helpers/health.svg)](https://phpackages.com/packages/sebastiaanluca-laravel-helpers)
```

###  Alternatives

[ronasit/laravel-helpers

Provided helpers function and some helper class.

1475.7k13](/packages/ronasit-laravel-helpers)[appstract/laravel-response-macros

Extra Response Macro's for Laravel

321.5k](/packages/appstract-laravel-response-macros)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
