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

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

laravel-enso/helpers
====================

Helper classes dependency for Laravel Enso

4.0.10(1mo ago)8102.8k—8.5%620MITPHPPHP ^8.0CI failing

Since Mar 19Pushed 1mo ago4 watchersCompare

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

READMEChangelogDependencies (5)Versions (212)Used By (20)

Helpers
=======

[](#helpers)

[![License](https://camo.githubusercontent.com/7592493a270ce46de5cb47b4bf200fb98f420470031e08c88ad53611b98ba0c4/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2d656e736f2f68656c706572732f6c6963656e7365)](LICENSE)[![Stable](https://camo.githubusercontent.com/9f42bf9d7407dde9e042350c289f20f7f10700c05da93e545cd5796a8d24020e/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2d656e736f2f68656c706572732f76657273696f6e)](https://packagist.org/packages/laravel-enso/helpers)[![Downloads](https://camo.githubusercontent.com/931009fbdf522ebb7ae011b8267359a3f5514ee93f3178f3825102bc55b902b8/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2d656e736f2f68656c706572732f646f776e6c6f616473)](https://packagist.org/packages/laravel-enso/helpers)[![PHP](https://camo.githubusercontent.com/ef6afd4ccdaa708a9b1a0a353d6d03a13ca1f03887b8db701d4118dc30a6735a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e302532422d3737376262342e737667)](composer.json)[![Issues](https://camo.githubusercontent.com/156baecc3c6ce27b0e256eeb11808e65e7c1ce2c6406dfc16e7a039a06bc8d2e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6c61726176656c2d656e736f2f68656c706572732e737667)](https://github.com/laravel-enso/helpers/issues)[![Merge Requests](https://camo.githubusercontent.com/ba303d2b45ce7e762894c0679b9c1d323e2892933cfb33688e20233edf71f6dc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732d70722f6c61726176656c2d656e736f2f68656c706572732e737667)](https://github.com/laravel-enso/helpers/pulls)

Description
-----------

[](#description)

Helpers is a shared utility package for the Laravel Enso ecosystem.

It bundles small reusable services, model traits, request helpers, casts, enums, contracts, and exceptions that are consumed by many backend packages. The package is intentionally broad: instead of modelling one business feature, it centralizes low-level building blocks that would otherwise be duplicated across the ecosystem.

Typical use cases include precise decimal arithmetic, monetary calculations, JSON parsing, factory resolution in package models, request key normalization, active-state handling, seeder progress reporting, and a few convenience enums and casts.

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

[](#installation)

This package is usually installed transitively by other Enso backend packages.

For standalone installation:

```
composer require laravel-enso/helpers
```

No publishing step is required.

Features
--------

[](#features)

- Provides decimal-safe arithmetic helpers built on BCMath.
- Includes utility services for JSON reading, object wrapping, disk-size formatting, loan rates, pricing, chunk sizing, and factory resolution.
- Provides Eloquent and request traits for active state, request-key normalization, morph-map handling, observer cascading, and touch propagation.
- Provides a relation-load guard trait for resources and serializers that must fail fast when expected Eloquent relations were not eager loaded.
- Includes casts for encrypted strings and JSON-backed object payloads.
- Ships helper enums for VAT rates and payment methods.
- Provides ecosystem-level helper exceptions and a JSON-friendly `EnsoException`.
- Exposes an `Activatable` contract used by packages that model `is_active` semantics.

Usage
-----

[](#usage)

Use `Decimals` for precise arithmetic:

```
use LaravelEnso\Helpers\Services\Decimals;

$gross = Decimals::add('100.25', '19.75');
$vat = Decimals::mul('100', '0.19', 4);
```

Use `JsonReader` to load JSON in different formats:

```
use LaravelEnso\Helpers\Services\JsonReader;

$data = (new JsonReader($path))->array();
$obj = (new JsonReader($path))->obj();
```

Use `PriceComputor` for pricing totals:

```
use LaravelEnso\Helpers\Services\PriceComputor;

$total = (new PriceComputor('100'))
    ->quantity('2')
    ->discountPercent('10')
    ->vatPercent('19')
    ->total();
```

Normalize request keys before validation with `ToSnakeCase`:

```
use Illuminate\Foundation\Http\FormRequest;
use LaravelEnso\Helpers\Traits\ToSnakeCase;

class StoreCompany extends FormRequest
{
    use ToSnakeCase;
}
```

`ToSnakeCase` rewrites nested array keys recursively, so frontend payloads may use camelCase while backend validation rules remain snake\_case.

Guard required Eloquent relations before serializing relation-dependent payloads:

```
use Illuminate\Http\Resources\Json\JsonResource;
use LaravelEnso\Helpers\Traits\GuardRelationLoad;

class Project extends JsonResource
{
    use GuardRelationLoad;

    public function toArray($request): array
    {
        $flow = $this->guardRelationLoad($this->resource, 'flow');

        return [
            'flow' => $flow->name,
        ];
    }
}
```

The guard returns the loaded relation, so resources can use it directly after the load check.

Use Laravel's native validated input API to exclude validated fields:

```
$attributes = $request->safe()->except('roles');
```

### Deprecated Traits

[](#deprecated-traits)

The following traits are kept for backwards compatibility only and should not be used in new code:

- `FiltersRequest`; use `$request->safe()->except(...)`.
- `MapsRequestKeys`; use `ToSnakeCase`.
- `InCents`; use explicit model casts, accessors, and mutators for monetary values.

API
---

[](#api)

### Services

[](#services)

Core helpers:

- `Decimals`
- `JsonReader`
- `Obj`
- `FactoryResolver`
- `OptimalChunk`
- `DiskSize`

Financial helpers:

- `PriceComputor`
- `Loan`

Utility placeholder:

- `Dummy`

### Traits

[](#traits)

Model traits:

- `ActiveState`
- `AvoidsDeletionConflicts`
- `CascadesMorphMap`
- `CascadesObservers`
- `ForceableIndex`
- `GuardRelationLoad`
- `InCents` (deprecated)
- `UpdatesOnTouch`

Request / validation traits:

- `FiltersRequest` (deprecated)
- `MapsRequestKeys` (deprecated)
- `ToSnakeCase`
- `TransformMorphMap`

Seeder traits:

- `SeederProgress`
- `DatabaseSeedProgress`

### Casts

[](#casts)

- `LaravelEnso\Helpers\Casts\Encrypt`
- `LaravelEnso\Helpers\Casts\Obj`

### Enums

[](#enums)

- `LaravelEnso\Helpers\Enums\PaymentMethods`
- `LaravelEnso\Helpers\Enums\VatRates`

### Contracts

[](#contracts)

- `LaravelEnso\Helpers\Contracts\Activatable`

### Exceptions

[](#exceptions)

- `LaravelEnso\Helpers\Exceptions\EnsoException`
- `LaravelEnso\Helpers\Exceptions\InCents`
- `LaravelEnso\Helpers\Exceptions\JsonParse`

Depends On
----------

[](#depends-on)

Required Enso packages:

- [`laravel-enso/enums`](https://docs.laravel-enso.com/backend/enums.html) [↗](https://github.com/laravel-enso/enums)

Framework and runtime dependencies:

- [`laravel/framework`](https://github.com/laravel/framework) [↗](https://github.com/laravel/framework)
- [`doctrine/dbal`](https://github.com/doctrine/dbal) [↗](https://github.com/doctrine/dbal)

Contributions
-------------

[](#contributions)

are welcome. Pull requests are great, but issues are good too.

Thank you to all the people who already contributed to Enso!

###  Health Score

66

—

FairBetter than 99% of packages

Maintenance88

Actively maintained with recent releases

Popularity39

Limited adoption so far

Community39

Small or concentrated contributor base

Maturity88

Battle-tested with a long release history

 Bus Factor1

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

###  Release Activity

Cadence

Every ~16 days

Recently: every ~4 days

Total

204

Last Release

59d ago

Major Versions

1.15.20 → 2.0.02020-06-26

2.9.1 → 3.0.02024-01-09

3.3.0 → 4.0.02026-04-09

PHP version history (5 changes)1.0.2PHP &gt;=5.6.4

1.3.1PHP &gt;=7.1.0

1.15.0PHP &gt;=7.4.0

2.5.0PHP &gt;=8.0

3.0.0PHP ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16073274?v=4)[Adrian Ocneanu](/maintainers/aocneanu)[@aocneanu](https://github.com/aocneanu)

---

Top Contributors

[![aocneanu](https://avatars.githubusercontent.com/u/16073274?v=4)](https://github.com/aocneanu "aocneanu (246 commits)")[![gandesc](https://avatars.githubusercontent.com/u/14071925?v=4)](https://github.com/gandesc "gandesc (56 commits)")[![raftx24](https://avatars.githubusercontent.com/u/10864136?v=4)](https://github.com/raftx24 "raftx24 (16 commits)")[![vmcvlad](https://avatars.githubusercontent.com/u/37445394?v=4)](https://github.com/vmcvlad "vmcvlad (15 commits)")[![DevIonut](https://avatars.githubusercontent.com/u/19207797?v=4)](https://github.com/DevIonut "DevIonut (3 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (3 commits)")[![GITmanuela](https://avatars.githubusercontent.com/u/44998004?v=4)](https://github.com/GITmanuela "GITmanuela (2 commits)")[![jlsjonas](https://avatars.githubusercontent.com/u/932193?v=4)](https://github.com/jlsjonas "jlsjonas (1 commits)")[![AbdullahiAbdulkabir](https://avatars.githubusercontent.com/u/33360580?v=4)](https://github.com/AbdullahiAbdulkabir "AbdullahiAbdulkabir (1 commits)")[![codacy-badger](https://avatars.githubusercontent.com/u/23704769?v=4)](https://github.com/codacy-badger "codacy-badger (1 commits)")

---

Tags

enso-helperslaravellaravel-ensolaravel-packagehelperslaravel-enso

### Embed Badge

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

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

###  Alternatives

[backpack/crud

Quickly build admin interfaces using Laravel, Bootstrap and JavaScript.

3.4k3.7M223](/packages/backpack-crud)[laravel-enso/tables

Server-side data tables and export backend for Laravel Enso

63355.1k84](/packages/laravel-enso-tables)[ronasit/laravel-helpers

Provided helpers function and some helper class.

2085.6k31](/packages/ronasit-laravel-helpers)[laravel-enso/forms

JSON-based form builder for Laravel Enso

12354.2k85](/packages/laravel-enso-forms)[dcat-plus/laravel-admin

dcat-plus admin

1474.0k10](/packages/dcat-plus-laravel-admin)[ronasit/laravel-entity-generator

Provided console command for generating entities.

2053.1k](/packages/ronasit-laravel-entity-generator)

PHPackages © 2026

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