EgameItem.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace App\Models;
  3. class EgameItem extends BaseModel
  4. {
  5. public const TYPE_CATEGORY = 'category';
  6. public const TYPE_PLATFORM = 'platform';
  7. public const TYPE_GAME = 'game';
  8. public const PLATFORM_SCOPE_GLOBAL = 'global';
  9. public const PLATFORM_SCOPE_CATEGORY = 'category';
  10. public const STATUS_DISABLED = 0;
  11. public const STATUS_ENABLED = 1;
  12. protected $table = 'egame_items';
  13. protected $fillable = [
  14. 'item_type',
  15. 'plat_type',
  16. 'game_type',
  17. 'game_code',
  18. 'name',
  19. 'ingress',
  20. 'lobby_enabled',
  21. 'logo',
  22. 'logo_langs',
  23. 'status',
  24. 'sort',
  25. ];
  26. protected $casts = [
  27. 'game_type' => 'integer',
  28. 'lobby_enabled' => 'integer',
  29. 'logo_langs' => 'array',
  30. 'status' => 'integer',
  31. 'sort' => 'integer',
  32. ];
  33. public function isCategory(): bool
  34. {
  35. return $this->item_type === self::TYPE_CATEGORY;
  36. }
  37. public function isGlobalPlatform(): bool
  38. {
  39. return $this->item_type === self::TYPE_PLATFORM && $this->game_type === 0;
  40. }
  41. public function isPlatformRelation(): bool
  42. {
  43. return $this->item_type === self::TYPE_PLATFORM && $this->game_type > 0;
  44. }
  45. }