PHPackages                             tyler36/laravel-helper-macros - 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. tyler36/laravel-helper-macros

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

tyler36/laravel-helper-macros
=============================

Collection of Helpers and macros for Laravel

1.0.1(9y ago)3831PHP

Since Dec 2Pushed 4y ago1 watchersCompare

[ Source](https://github.com/tyler36/laravel-helper-macros)[ Packagist](https://packagist.org/packages/tyler36/laravel-helper-macros)[ RSS](/packages/tyler36-laravel-helper-macros/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (1)Dependencies (2)Versions (3)Used By (0)

Laravel Helpers
===============

[](#laravel-helpers)

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

[](#installation)

1.Install package through composer.

```
   composer require tyler36/laravel-helper-macros

```

2.Add package to `config/app.php`

```
    Tyler36\laravelHelpers\LaravelHelperServiceProvider::class,

```

---

Helpers
-------

[](#helpers)

### Validator

[](#validator)

Inspired by [Validate (almost) anything in Laravel](https://murze.be/2015/11/validate-almost-anything-in-laravel/). Uses Laravel Validator class to validate anything.

EG. Validate Date (expects FALSE):

```
    tyler36\laravelHelpers\Helper::validate('20150230', 'date');

```

EG. Validate Date (expects TRUE):

```
    tyler36\laravelHelpers\Helper::validate('20150230', 'date');

```

Macros
------

[](#macros)

### Collections

[](#collections)

These macros extend **collection** functionality.

#### pipe

[](#pipe)

Inspired by [The pipe collection macro](https://murze.be/2016/05/getting-package-statistics-packagist-redux/). Pass collection to a function.

```
$collect = collect([1, 2, 3])
    ->pipe(function ($data) {
        return $data->merge([4, 5, 6]);
    });

```

#### dd

[](#dd)

Inspired by [Debugging collections](https://murze.be/2016/06/debugging-collections/). Debug a collection by 'dump and die' the current state. Can be used mid-chain to break and dump.

```
collect($items)
  ->filter(function() {
     ...
   })
  ->dd()

```

#### ifEmpty

[](#ifempty)

Run callback if collection is empty.

```
$items = collect([]);
$items->ifEmpty(function(){
    abort(500, 'No items');
});

```

#### ifAny

[](#ifany)

Run callback if collection has data ( &gt;1 item).

```
$errors = collect(['Something went wrong']);
$errors->ifAny(function(){
    abort(500, 'There was at-least 1 problem');
});

```

#### mapToAssoc

[](#maptoassoc)

Convert collection to associative array Inspired by [Customizing Keys When Mapping Collections](https://adamwathan.me/2016/07/14/customizing-keys-when-mapping-collections/)

```
$emailLookup = $employees->mapToAssoc(function ($employee) {
    return [$employee['email'], $employee['name']];
});

```

### Response

[](#response)

These macros help to standardize **api json response** returns throughout the application. Inspired by [Laravel Response Macros for APIs](https://blog.jadjoubran.io/2016/03/27/laravel-response-macros-api/)

#### Success

[](#success)

Returns payload ($data) with a [HTTP status code 200](https://httpstatuses.com/200)

```
response()->success($data);

```

EG.

```
response()->success(['earth' => 3, 'sun' => 'yellow'])

```

Returns **HTTP status 200** with the following:

```
{"errors":false,"data":{"earth":3,"sun":"yellow"}}

```

#### noContent

[](#nocontent)

Returns empty content with a [HTTP status code 402](https://httpstatuses.com/204)

```
response()->noContent()

```

#### Error

[](#error)

Returns message ($message) content with an optional [HTTP status code](https://httpstatuses.com/) ($statusCode) \[Default: [HTTP status code 400](https://httpstatuses.com/400)\]

```
response()->error($message);

```

Eg.

```
response()->error('There was an error.');

```

Returns **HTTP status 400** with the following:

```
{"errors":true,"message":"There was an error."}

```

Eg.

```
response()->error('Not authorized!', 403);

```

Returns **HTTP status 403** with the following:

```
{"errors":true,"message":"Not authorized!"}

```

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 66.7% 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 ~0 days

Total

2

Last Release

3498d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7234392?v=4)[tyler36](/maintainers/tyler36)[@tyler36](https://github.com/tyler36)

---

Top Contributors

[![s-hendrix-iqnet](https://avatars.githubusercontent.com/u/180614482?v=4)](https://github.com/s-hendrix-iqnet "s-hendrix-iqnet (10 commits)")[![tyler36](https://avatars.githubusercontent.com/u/7234392?v=4)](https://github.com/tyler36 "tyler36 (3 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/tyler36-laravel-helper-macros/health.svg)

```
[![Health](https://phpackages.com/badges/tyler36-laravel-helper-macros/health.svg)](https://phpackages.com/packages/tyler36-laravel-helper-macros)
```

###  Alternatives

[symfony/polyfill-php54

Symfony polyfill backporting some PHP 5.4+ features to lower PHP versions

9731.1M5](/packages/symfony-polyfill-php54)[kevinchappell/form-builder

jQuery formBuilder

2.7k7.1k2](/packages/kevinchappell-form-builder)[byrokrat/accounting

Analysis and generation of bookkeeping data according to Swedish standards

121.6k](/packages/byrokrat-accounting)

PHPackages © 2026

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