GameRewardGroup.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace App\Module\Game\Models;
  3. use Illuminate\Database\Eloquent\Relations\HasMany;
  4. use UCore\ModelCore;
  5. /**
  6. * 奖励组
  7. *
  8. * field start
  9. * @property int $id 主键
  10. * @property string $name 奖励组名称
  11. * @property string $code 奖励组编码(唯一)
  12. * @property string $description 奖励组描述
  13. * @property int $is_random 是否随机发放(0:全部发放, 1:随机发放)
  14. * @property int $random_count 随机发放时的奖励数量
  15. * @property \Carbon\Carbon $created_at 创建时间
  16. * @property \Carbon\Carbon $updated_at 更新时间
  17. * field end
  18. */
  19. class GameRewardGroup extends ModelCore
  20. {
  21. /**
  22. * 与模型关联的表名
  23. *
  24. * @var string
  25. */
  26. protected $table = 'game_reward_groups';
  27. // attrlist start
  28. protected $fillable = [
  29. 'id',
  30. 'name',
  31. 'code',
  32. 'description',
  33. 'is_random',
  34. 'random_count',
  35. ];
  36. // attrlist end
  37. /**
  38. * 应该被转换为原生类型的属性
  39. *
  40. * @var array
  41. */
  42. protected $casts = [
  43. 'is_random' => 'boolean',
  44. 'random_count' => 'integer',
  45. ];
  46. /**
  47. * 获取奖励组中的所有奖励项
  48. *
  49. * @return HasMany
  50. */
  51. public function rewardItems(): HasMany
  52. {
  53. return $this->hasMany(GameRewardItem::class, 'group_id', 'id');
  54. }
  55. }