PHPackages                             googleshokry/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. googleshokry/laravel-helpers

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

googleshokry/laravel-helpers
============================

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

00PHP

Since Oct 29Pushed 7y ago1 watchersCompare

[ Source](https://github.com/googleshokry/laravel-helpers)[ Packagist](https://packagist.org/packages/googleshokry/laravel-helpers)[ RSS](/packages/googleshokry-laravel-helpers/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

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

[![Latest stable release](https://camo.githubusercontent.com/a51199f68e0bb1c1d4cd49e6b48b187f6339d6f9ed0ba672d93103feed9f04e5/68747470733a2f2f706f7365722e707567782e6f72672f676f6f676c6573686f6b72792f6c61726176656c2d68656c706572732f76657273696f6e)](https://packagist.org/packages/googleshokry/laravel-helpers)[![Software license](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](LICENSE.md)[![Build status](https://camo.githubusercontent.com/c6121ac3cbb863b5e50f23a1f79fd63f1c66a85e329f4b0da91be47353ef8852/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f676f6f676c6573686f6b72792f6c61726176656c2d68656c706572732f6d61737465722e737667)](https://travis-ci.org/googleshokry/laravel-helpers)[![Total downloads](https://camo.githubusercontent.com/d6baf85583c2e4ee2e8f2d615574b57d4176f8cacfef9748624832397501e2d2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f676f6f676c6573686f6b72792f6c61726176656c2d68656c706572732e737667)](https://packagist.org/packages/googleshokry/laravel-helpers)

[![View my other packages and projects](https://camo.githubusercontent.com/5ce3a83ee0ec2b4ae47a99f67347c1d8e78582757eca80fe31c98e5bd0e2185a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c696e6b2d6f746865725f7061636b616765732d6c69676874677265792e737667)](https://packagist.org/packages/googleshokry)[![Follow @googleshokry on Twitter](https://camo.githubusercontent.com/343b369715c00bd885392ec875c39021e27eed259a2a66b1ab3d674275afdf65/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f666f6c6c6f772f676f6f676c6573686f6b72792e7376673f7374796c653d736f6369616c)](https://twitter.com/googleshokry)[![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@googleshokry%20https://github.com/googleshokry/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.2 or higher
- Laravel 5.6 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 googleshokry/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 [googleshokry/php-helpers](https://github.com/googleshokry/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.

In addition, the minimum requirements have been upgraded to PHP 7.2 and Laravel 5.6.

[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)

- [googleshokry](https://github.com/googleshokry)
- 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\]\[link-portfolio\] for more information, \[my blog\]\[link-blog\] for the latest tips and tricks, and my other [packages](https://packagist.org/packages/googleshokry) to kick-start your next project.

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

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 97.5% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/e96c062494bfb776a10cb236e9b56451617925f7e30828ea8df6e4569c0e5e9d?d=identicon)[googleshokry](/maintainers/googleshokry)

---

Top Contributors

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

### Embed Badge

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

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

PHPackages © 2026

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