laravel-enso/helpers is a Laravel package for helper classes dependency for laravel enso.
It currently has 8 GitHub stars and 102.598 downloads on Packagist (latest version 4.0.10).
Install it with composer require laravel-enso/helpers.
Discover more Laravel packages by laravel-enso
or browse all Laravel packages to compare alternatives.
Last updated
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.
This package is usually installed transitively by other Enso backend packages.
For standalone installation:
composer require laravel-enso/helpers
No publishing step is required.
EnsoException.Activatable contract used by packages that model is_active semantics.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');
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.Core helpers:
DecimalsJsonReaderObjFactoryResolverOptimalChunkDiskSizeFinancial helpers:
PriceComputorLoanUtility placeholder:
DummyModel traits:
ActiveStateAvoidsDeletionConflictsCascadesMorphMapCascadesObserversForceableIndexGuardRelationLoadInCents (deprecated)UpdatesOnTouchRequest / validation traits:
FiltersRequest (deprecated)MapsRequestKeys (deprecated)ToSnakeCaseTransformMorphMapSeeder traits:
SeederProgressDatabaseSeedProgressLaravelEnso\Helpers\Casts\EncryptLaravelEnso\Helpers\Casts\ObjLaravelEnso\Helpers\Enums\PaymentMethodsLaravelEnso\Helpers\Enums\VatRatesLaravelEnso\Helpers\Contracts\ActivatableLaravelEnso\Helpers\Exceptions\EnsoExceptionLaravelEnso\Helpers\Exceptions\InCentsLaravelEnso\Helpers\Exceptions\JsonParseRequired Enso packages:
Framework and runtime dependencies:
are welcome. Pull requests are great, but issues are good too.
Thank you to all the people who already contributed to Enso!