wboyz / laravel-enum
Base enum class with some features.
Installs: 11 747
Dependents: 0
Suggesters: 0
Security: 0
Stars: 8
Watchers: 4
Forks: 2
Open Issues: 0
Type:helper
Requires
- php: >=5.5.9
Requires (Dev)
- phpunit/phpunit: 5.3.*
This package is auto-updated.
Last update: 2024-10-29 04:31:08 UTC
README
Create a base enum class to laravel framework.
Installation
Require this package with composer:
composer require wboyz/laravel-enum
General Use
use WBoyz\LaravelEnum\BaseEnum; class Fruits extends BaseEnum { const APPLE = 1; const PEACH = 2; const PEAR = 3; } ... $values = Fruits::getValues(); // [1, 2, 3] $keys = Fruits::getKeys(); // ['APPLE', 'PEACH', 'PEAR'] $dictionary = Fruits::toDictionary(); // ['APPLE' => 1, 'PEACH' => 2, 'PEAR' => 3] $result = Fruits::hasValue(1); // true $result = Fruits::hasKey('APPLE'); // true $result = Fruits::getValue('APPLE'); // 1 $result = Fruits::getValue('MELON'); // 0