mad-web / laravel-enum Goto Github PK
View Code? Open in Web Editor NEWElegant Enum implementation for Laravel
License: MIT License
Elegant Enum implementation for Laravel
License: MIT License
Method getConstList should be static (available in class Enum)
Create your UserEnumStatus class extending Enum
Call this function... UserEnumStatus::getConstList();
Are you going to support PHP 8 right now?
Have a enum:
/**
* @method static BotKeywordType STRING()
* @method static BotKeywordType EMAIL()
* @method static BotKeywordType PHONE()
*/
final class KeywordType extends Enum
{
//const __default = self::STRING;
const STRING = 'string';
const EMAIL = 'email';
const PHONE = 'phone';
}
When use
var_dump(KeywordType::toArray(false));
result:
array (size=4)
'STRING' => string 'string' (length=6)
'EMAIL' => string 'email' (length=5)
'PHONE' => string 'phone' (length=5)
'__default' => null
But if i set default value - all ok, __default key not present...
Hi, can you upgrade to Laravel 9? Thanks
class TestModel extends Model
{
use EnumCastable;
protected $casts = [
'test_nullable_enum_field' => TestEnum::class,
];
}
$model = TestModel::whereNull('test_nullable_enum_field')->first();
return $model->test_nullable_enum_field;
Expectation: null
Real: UnexpectedValueException : Value '' is not part of the enum TestEnum
Please fix this problem, and add support for nullable fields
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.