Download the PHP package omaradel/enum without Composer
On this page you can find all versions of the php package omaradel/enum. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download omaradel/enum
More information about omaradel/enum
Files in omaradel/enum
Package enum
Short Description An Enum package for Laravel provides an elegant and type-safe way to define and use enumerations in your Laravel application. Enumerations (Enums) are useful for representing a fixed set of constants with meaningful names, like user roles, order statuses, or payment methods.
License MIT
Informations about the package enum
Laravel Enum Package
A Laravel package that provides an easy and efficient way to work with enums in PHP, enhancing code readability and maintainability.
Features
- Enum Definition: Define enums using a straightforward syntax.
- Value Retrieval: Retrieve enum values seamlessly.
- Key Retrieval: Access enum keys with ease.
- Array Conversion: Convert enums to arrays for flexible usage.
- Validation Rules: Integrate enum validation rules within Laravel's validation system.
- Localization Support: Support for translating enum values using Laravel's localization features.
Installation
Install the package via Composer:
Usage
Defining an Enum
Create a new enum by extending the Enum
class:
Retrieving Enum Values
Access the value of an enum:
Retrieving Enum Keys
Get the key associated with a specific value:
Converting Enum to Array
Convert the enum to an associative array:
Validation
Use the enum in Laravel's validation rules:
Localization
To localize enum values, add translations in your /lang/vendor/enum
files:
resources/lang/vendor/enum/en/user_roles.php:
Then, retrieve the localized value:
To publish the translations files:
Predefined Classes:
1- BaseUserEnum Class:
2- BaseStatusEnum Class:
3- BaseUserStatusEnum Class:
Contributing
Contributions are welcome! Please submit a pull request or open an issue to discuss improvements or features.
License
This package is open-sourced software licensed under the MIT license.