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

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

mrkatz/laravel-helpers
======================

Collection Of Laravel Helpers

092PHPCI failing

Since Nov 10Pushed 6y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

A collection of awesome helpful functions for Laravel
=====================================================

[](#a-collection-of-awesome-helpful-functions-for-laravel)

[![GitHub license](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)[![Packagist Version](https://camo.githubusercontent.com/0c6e142146252853f3dce29a0cc934cb247bbe524daa282f2868b518a9366aa5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d726b61747a2f6c61726176656c2d68656c706572732e7376673f6d61784167653d30)](https://packagist.org/packages/mrkatz/laravel-helpers)[![Packagist Version](https://camo.githubusercontent.com/0c6e142146252853f3dce29a0cc934cb247bbe524daa282f2868b518a9366aa5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d726b61747a2f6c61726176656c2d68656c706572732e7376673f6d61784167653d30)](https://packagist.org/packages/mrkatz/laravel-helpers)[![Packagist Stats](https://camo.githubusercontent.com/2fef35fca26030fa9be7f1d16e8e446a51437140195e7216e693c305a817edc8/68747470733a2f2f706f7365722e707567782e6f72672f6d726b61747a2f6c61726176656c2d68656c706572732f646f776e6c6f616473)](https://packagist.org/packages/mrkatz/laravel-helpers/stats)[![Travis CI status image](https://camo.githubusercontent.com/53b8a5f443ebaf2670c036cc355be76d26852de2a838e86b916064c5d2d41df9/68747470733a2f2f7472617669732d63692e636f6d2f6d726b61747a2f6c61726176656c2d68656c706572732e7376673f6272616e63683d6d6173746572)](https://camo.githubusercontent.com/53b8a5f443ebaf2670c036cc355be76d26852de2a838e86b916064c5d2d41df9/68747470733a2f2f7472617669732d63692e636f6d2f6d726b61747a2f6c61726176656c2d68656c706572732e7376673f6272616e63683d6d6173746572)

Extending calebporzio/awesome-helpers package.

Installation
------------

[](#installation)

```
composer require mrkatz/laravel-helpers
```

Helpers
-------

[](#helpers)

**carbon**

Shortcut for: `new Carbon` or `Carbon::parse()`

```
carbon('One year ago');
```

**chain**

Makes an ordinary object chainable.

```
chain(new SomeClass)
    ->firstMethod()
    ->secondMethod()
    ->thirdMethod();

// You can use the "carry" constant to pass the result of one method into the other:
chain(new Str)->singular('cars')->ucfirst(carry)();
// Returns "Car"
// Also, you can grab the result of the chain by trailing
// a "()" on the end of it. (Thanks to Taylor Otwell for these two additions)
```

**connection**

Run callback under a different database connection.

```
$tenantPostIds = connection('tenantdb', function () {
    return Post::pluck('id');
});
```

**dump\_sql**

Returns sql query with bindings data.

```
dump_sql(\DB::table('users')->where('email', "blaBla")->where('id', 1));
// returns "select * from `users` where `email` = 'blaBla' and `id` = 1"
```

**faker**

Shortcut for: `$faker = Faker\Factory::create()`

```
faker()->address; // returns random, fake address
faker('address'); // alternate syntax
```

**user**

A shortcut for `auth()->user()`

```
user()->posts()->create([...]);
```

**money**

```
echo money(12); // echoes "$12.00"
echo money(12.75); // echoes "$12.75"
echo money(12.75, false); // echos "$13"
echo money(12.75, true, 'en_GB'); // echos "£12.75"
// Note: unless specified otherwise, money() will detect the current locale.
```

**ok**

Shortcut for `response('', 204)`. When you don't have anything to return from an endpoint, but you want to return success.

```
return ok();
```

**stopwatch**

Returns the amount of time (in seconds) the provided callback took to execute. Useful for debugging and profiling.

```
stopwatch(function () {
    sleep(2);
}); // returns "2.0"
```

**str\_between**

```
str_between('--thing--', '--'); // returns "thing"
str_between('[thing]', '[', ']'); // returns "thing"

Str::between('--thing--', '--'); // returns "thing"
Str::between('[thing]', '[', ']'); // returns "thing"
```

**str\_extract**

Returns capture groups contained in the provided regex pattern.

```
str_extract('Jan-01-2019', '/Jan-(.*)-2019/'); // returns "01"

Str::extract('Jan-01-2019', '/Jan-(.*)-2019/'); // returns "01"
```

**str\_match**

Checks the provided string against the provided regex pattern.

```
str_match('Jan-01-2019', '/Jan-.*-2019/'); // returns true
str_match('foo bar baz', 'bar'); // returns true

Str::match('Jan-1-2019', '/Jan-(.*)-2019/'); // returns true
```

**str\_validate**

A simple way to use validate a string using Laravel's built-in validation system.

```
str_validate('calebporzio@aol.com', 'regex:/\.net$/|email|max:10');
// returns: ["Format is invalid.", "May not be greater than 10 characters."]

Str::validate('calebporzio@aol.com', 'regex:/\.net$/|email|max:10');
// returns: ["Format is invalid.", "May not be greater than 10 characters."]
```

**str\_wrap**

```
str_wrap('thing', '--'); // returns "--thing--"

Str::wrap('thing', '--'); // returns "--thing--"
```

**swap**

This function swaps the values of two variables.

```
$startDate = '2040-01-01';
$endDate = '2020-01-01';

if ($endDate < $startDate) {
    swap($startDate, $endDate);
}

echo $startDate; // prints "2020-01-01"
echo $endDate; // prints "2040-01-01"
```

**tinker**

Kind of like `dd()`, but will open an `artisan tinker` terminal session with the variables you passed in, so you can play around.

```
$somethingYouWantToDebug = new StdClass;
tinker($somethingYouWantToDebug);
```

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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/1a3d3c1e3e518d9d21d6cc1bf1bb51e00e176d682cf4ed1c19c362bf6190173c?d=identicon)[mrkatz](/maintainers/mrkatz)

---

Top Contributors

[![mrkatz](https://avatars.githubusercontent.com/u/12110409?v=4)](https://github.com/mrkatz "mrkatz (5 commits)")

### Embed Badge

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

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

PHPackages © 2026

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