'电脑网页', 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 { $network = (string) $network; if ($network === '') { return '不限制'; } return self::NETWORK_LABELS[$network] ?? ''; } public static function optionList(array $labels): array { $options = []; foreach ($labels as $value => $label) { $options[] = ['value' => $value, 'label' => $label]; } return $options; } }