12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- /*
- * This file is part of the Jiannei/lumen-api-starter.
- *
- * (c) Jiannei <longjian.huang@foxmail.com>
- *
- * This source file is subject to the MIT license that is bundled
- * with this source code in the file LICENSE.
- */
- namespace App\Repositories\Enums;
- use Illuminate\Support\Str;
- use Jiannei\Enum\Laravel\Contracts\LocalizedEnumContract;
- use Jiannei\Enum\Laravel\FlaggedEnum;
- class RoleEnum extends FlaggedEnum implements LocalizedEnumContract
- {
- // const GUEST = 1 << 0;
- // const ADMIN = 1 << 1;
- // const SUPER_ADMIN = self::GUEST | self::ADMIN;
- const SUPER_ADMIN = 'admin';
- const SHOP_ADMIN = 'shop_admin';
- const COACH_VR = 'coach-vr';
- const COACH_CAR = 'coach-car';
- const BUSINESS = 'business';
- const BUSINESS_TEMP = 'business-temp';
- const CAIWU = 'caiwu';
- const YUNYING = 'yunying';
- public $name;
- public function __construct($flags)
- {
- parent::__construct($flags);
- $this->name = Str::ucfirst(Str::lower(Str::of($this->key)->replace('_', ' ')));
- }
- public static function makeRoles(): array
- {
- $rawRoles = self::getInstances();
- collect($rawRoles)->each(function ($item, $key) use (&$roles) {
- if ($item->value !== self::NONE) {
- $roles[] = ['name' => $item->name];
- }
- });
- return $roles;
- }
- }
|