<?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;

    protected $table = 'egame_items';

    protected $fillable = [
        'item_type',
        'plat_type',
        'game_type',
        'game_code',
        'name',
        'ingress',
        'lobby_enabled',
        'logo',
        '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;
    }
}
