| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <?php
- namespace App\Models;
- class EgameItem extends BaseModel
- {
- public const TYPE_CATEGORY = 'category';
- public const TYPE_PLATFORM = 'platform';
- public const TYPE_GAME = 'game';
- public const PLATFORM_SCOPE_GLOBAL = 'global';
- public const PLATFORM_SCOPE_CATEGORY = 'category';
- public const STATUS_DISABLED = 0;
- public const STATUS_ENABLED = 1;
- public const INGRESS_PC = '1';
- public const INGRESS_MOBILE = '2';
- public const INGRESS_BOTH = '3';
- public const NETWORK_MAINLAND = 'mainland';
- public const NETWORK_HK = 'hk';
- public const NETWORK_KR = 'kr';
- public const NETWORK_JP = 'jp';
- public const INGRESS_LABELS = [
- self::INGRESS_PC => '电脑网页',
- self::INGRESS_MOBILE => '手机网页',
- self::INGRESS_BOTH => '电脑/手机网页',
- ];
- public const NETWORK_LABELS = [
- self::NETWORK_MAINLAND => '大陆',
- self::NETWORK_HK => '香港',
- self::NETWORK_KR => '韩国',
- self::NETWORK_JP => '日本',
- ];
- public const STATUS_LABELS = [
- self::STATUS_ENABLED => '启用',
- self::STATUS_DISABLED => '停用',
- ];
- protected $table = 'egame_items';
- protected $fillable = [
- 'item_type',
- 'plat_type',
- 'game_type',
- 'game_code',
- 'name',
- 'description',
- 'ingress',
- 'network',
- 'lobby_enabled',
- 'logo',
- 'logo_h5',
- 'logo_langs',
- 'status',
- 'sort',
- ];
- protected $casts = [
- 'game_type' => 'integer',
- 'lobby_enabled' => 'integer',
- 'logo_langs' => 'array',
- 'status' => 'integer',
- 'sort' => 'integer',
- ];
- public function isCategory(): bool
- {
- return $this->item_type === self::TYPE_CATEGORY;
- }
- public function isGlobalPlatform(): bool
- {
- return $this->item_type === self::TYPE_PLATFORM && $this->game_type === 0;
- }
- public function isPlatformRelation(): bool
- {
- return $this->item_type === self::TYPE_PLATFORM && $this->game_type > 0;
- }
- public static function ingressValues(): array
- {
- return array_keys(self::INGRESS_LABELS);
- }
- public static function networkValues(): array
- {
- return array_keys(self::NETWORK_LABELS);
- }
- public static function ingressName(?string $ingress): string
- {
- return self::INGRESS_LABELS[(string) $ingress] ?? '';
- }
- public static function networkName(?string $network): string
- {
- return self::NETWORK_LABELS[(string) $network] ?? '';
- }
- public static function optionList(array $labels): array
- {
- $options = [];
- foreach ($labels as $value => $label) {
- $options[] = ['value' => $value, 'label' => $label];
- }
- return $options;
- }
- }
|