Package Data | |
---|---|
Maintainer Username: | nalatreb |
Maintainer Contact: | bertalan.verebelyi@gmail.com (Bertalan Verebelyi) |
Package Create Date: | 2016-04-02 |
Package Last Update: | 2016-04-19 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-18 03:03:55 |
Package Statistics | |
---|---|
Total Downloads: | 11,813 |
Monthly Downloads: | 188 |
Daily Downloads: | 0 |
Total Stars: | 8 |
Total Watchers: | 4 |
Total Forks: | 2 |
Total Open Issues: | 0 |
Create a base enum class to laravel framework.
Require this package with composer:
composer require wboyz/laravel-enum
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