pentacore / laravel-utils
A collection of commonly used Laravel utilities, traits, and helpers.
v1.0.2
2026-05-07 10:41 UTC
Requires
- php: ^8.3 || ^8.4 || ^8.5
- illuminate/contracts: ^11.0 || ^12.0 || ^13.0
- illuminate/support: ^11.0 || ^12.0 || ^13.0
- illuminate/validation: ^11.0 || ^12.0 || ^13.0
Requires (Dev)
- laravel/boost: ^2.4
- laravel/pint: ^1.18
- orchestra/testbench: ^9.0 || ^10.0 || ^11.0
- pestphp/pest: ^3.0 || ^4.0
- pestphp/pest-plugin-laravel: ^3.0 || ^4.0
- rector/rector: ^2.0
README
A collection of commonly used Laravel utilities, traits, and helpers.
Requirements
- PHP
^8.3 - Laravel
^11.0 || ^12.0 || ^13.0
Installation
composer require pentacore/laravel-utils
The service provider is auto-discovered.
Utilities
EnumUtils trait
Adds a set of helpers to any backed enum.
use Pentacore\LaravelUtils\Concerns\EnumUtils; enum Status: string { use EnumUtils; case Active = 'active'; case Pending = 'pending'; case Archived = 'archived'; }
| Method | Description |
|---|---|
Status::names() |
Array of case names. |
Status::values() |
Array of backing values. |
Status::array() |
Associative array [value => name]. |
Status::validationRule() |
Rule::in(values) for use in form requests / validators. |
Status::iterator() |
Generator keyed by case name. |
Status::mapForSelect($withNull, $labelKey) |
Sorted [label, value] list for select dropdowns. |
Status::commaSeparatedValues() |
Comma-separated string of values. |
$case->asSlug() |
URL-friendly slug of the value. |
$case->toString() |
Value cast to string. |
$case->equals($value) |
Strict comparison of value. |
If a case implements a label() method, mapForSelect() will use it instead of the case name.
Testing
composer test
License
MIT