Comments (5)
@rsubr Yes, this looks good to me. I'll add something like it in when I get a chance.
I was also thinking about making a better default for the getDescription method where it could guess a description for a key name e.g. SuperAdministrator
would become Super administrator
.
Glad you find the package useful 👍
from laravel-enum.
@rsubr I've added a toSelectArray
method. If you have any other methods that you often add to an enum, I've made the base Enum class macroable so you can extend it as you wish within your application.
https://github.com/BenSampo/laravel-enum#extending-the-enum-base-class
from laravel-enum.
@BenSampo works great! 🙏
Thanks for making it extensible.
You have even updated the project documentation! 😲 🏆
from laravel-enum.
Further testing shows that getDescription
method defined in my UserType
child class does not get called by toSelectArray
. It's calling the method defined in the Enum
base class function instead.
In the toSelectArray
method, can you please change self::getDescription
to static::getDescription
so the overridden getDescription
from the child class will be called?
There's the code that needs to be changed:
foreach ($array as $key => $value) {
// $selectArray[$value] = self::getDescription($value);
$selectArray[$value] = static::getDescription($value);
}
from laravel-enum.
@rsubr Yeah well spotted - have just pushed a fix for that.
from laravel-enum.
Related Issues (20)
- Optional enum validaiton. HOT 1
- classDeclarationOffset unavailable when content removed with existing docblock HOT 6
- Support Laravel 10 HOT 1
- asSelectArray no return description localization HOT 2
- `enum:annotate` command breaks existing docblock descriptions
- add extra attributes HOT 2
- Adding extra Attributes HOT 4
- localization path HOT 1
- Calling translator in boot breaks translation loading HOT 3
- validateEnumValue does not exist HOT 9
- Add `$hidden` property to Enums HOT 1
- I am stepping down from feature development
- Enum returns incomparable instances HOT 1
- EnumServiceProvider breaks nova translations HOT 3
- Can't install on php8.3.1 HOT 4
- Installation problem HOT 2
- Dump phpunit/phpunit to v11 HOT 1
- Error when converting enums using the rector command HOT 1
- False positive when converting to native enums HOT 2
- Upgrade to laravel 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-enum.