PetBattleSeason.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace App\Module\Pet\Models;
  3. use UCore\ModelCore;
  4. use Illuminate\Database\Eloquent\Relations\HasMany;
  5. /**
  6. * 宠物争霸赛赛季模型
  7. *
  8. * field start
  9. * @property int $id
  10. * @property string $name 赛季名称
  11. * @property string $start_time 开始时间
  12. * @property string $end_time 结束时间
  13. * @property int $boss_power Boss战力
  14. * @property object|array $reward_pool 奖池配置
  15. * @property int $status 状态:0未开始,1进行中,2已结束
  16. * @property \Carbon\Carbon $created_at
  17. * @property \Carbon\Carbon $updated_at
  18. * field end
  19. */
  20. class PetBattleSeason extends ModelCore
  21. {
  22. /**
  23. * 赛季状态常量
  24. */
  25. const STATUS_NOT_STARTED = 0; // 未开始
  26. const STATUS_IN_PROGRESS = 1; // 进行中
  27. const STATUS_ENDED = 2; // 已结束
  28. /**
  29. * 与模型关联的表名
  30. *
  31. * @var string
  32. */
  33. protected $table = 'pet_battle_seasons';
  34. // attrlist start
  35. protected $fillable = [
  36. 'id',
  37. 'name',
  38. 'start_time',
  39. 'end_time',
  40. 'boss_power',
  41. 'reward_pool',
  42. 'status',
  43. ];
  44. // attrlist end
  45. /**
  46. * 应该被转换为日期的属性
  47. *
  48. * @var array
  49. */
  50. protected $dates = [
  51. 'start_time',
  52. 'end_time',
  53. 'created_at',
  54. 'updated_at',
  55. ];
  56. /**
  57. * 应该被转换为原生类型的属性
  58. *
  59. * @var array
  60. */
  61. protected $casts = [
  62. 'boss_power' => 'integer',
  63. 'reward_pool' => 'json',
  64. 'status' => 'integer',
  65. ];
  66. /**
  67. * 获取赛季的所有队伍
  68. *
  69. * @return HasMany
  70. */
  71. public function teams(): HasMany
  72. {
  73. return $this->hasMany(PetBattleTeam::class, 'season_id');
  74. }
  75. }