Download the PHP package rawnoq/laravel-enum without Composer
On this page you can find all versions of the php package rawnoq/laravel-enum. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download rawnoq/laravel-enum
More information about rawnoq/laravel-enum
Files in rawnoq/laravel-enum
Download rawnoq/laravel-enum
More information about rawnoq/laravel-enum
Files in rawnoq/laravel-enum
Vendor rawnoq
Package laravel-enum
Short Description A comprehensive Laravel package for working with PHP Enums, providing casting, validation, translation, query scopes, and more
License MIT
Package laravel-enum
Short Description A comprehensive Laravel package for working with PHP Enums, providing casting, validation, translation, query scopes, and more
License MIT
Please rate this library. Is it a good library?
Informations about the package laravel-enum
Rawnoq Laravel Enum
A comprehensive Laravel package for working with PHP Enums, providing casting, validation, translation, query scopes, and more.
Features
- ✅ Enum Helpers: Useful methods for working with enums (
values(),names(),random(),fromValue(), etc.) - ✅ Eloquent Casting: Automatic enum casting in Eloquent models
- ✅ Validation Rules: Built-in validation rules for enum values
- ✅ Translation Support: Easy translation of enum labels
- ✅ Query Scopes: Helper scopes for filtering by enum values
- ✅ Type Safety: Full type safety with PHP 8.2+ backed enums
Installation
Configuration
Publish the config file:
Usage
Basic Enum with Helpers
Eloquent Model Casting
Validation
Translation Support
Query Scopes
Helper Facade
Advanced Usage
Combining Multiple Traits
Custom Translation Namespace
Filtering and Mapping
API Reference
HasEnumHelpers Methods
values()- Get all enum valuesnames()- Get all enum namesfromValue($value)- Get enum by value (nullable)fromValueOrFail($value)- Get enum by value (throws exception)random()- Get random enum casetoArray()- Convert to associative arrayoptions()- Get options for select/dropdownhasValue($value)- Check if value existshasName($name)- Check if name existsfirst()- Get first enum caselast()- Get last enum casefilter($callback)- Filter enum casesmap($callback)- Map enum cases
HasEnumTranslation Methods
label()- Get translated label for current caselabelFor($locale)- Get translated label for specific localelabels()- Get all translated labelslabelsFor($locale)- Get all translated labels for localetranslationKey($case)- Get translation key for casetranslationNamespace()- Get translation namespacetranslationKeyFormat()- Get translation key format
HasEnumScopes Methods (for Models)
whereEnum($column, $value)- Filter by enum valuewhereEnumIn($column, $values)- Filter by multiple enum valueswhereEnumNotIn($column, $values)- Exclude enum values
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT
All versions of laravel-enum with dependencies
PHP Build Version
Package Version
Requires
php Version
^8.2
illuminate/support Version ^11.0|^12.0
illuminate/database Version ^11.0|^12.0
illuminate/validation Version ^11.0|^12.0
illuminate/support Version ^11.0|^12.0
illuminate/database Version ^11.0|^12.0
illuminate/validation Version ^11.0|^12.0
The package rawnoq/laravel-enum contains the following files
Loading the files please wait ...