GameRewardLog.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace App\Module\Game\Models;
  3. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  4. use UCore\ModelCore;
  5. /**
  6. * 奖励发放日志
  7. *
  8. * field start
  9. * @property int $id 主键
  10. * @property int $user_id 用户ID
  11. * @property int $group_id 奖励组ID
  12. * @property string $source_type 来源类型(task, activity, sign_in等)
  13. * @property int $source_id 来源ID
  14. * @property array $reward_items 发放的奖励项(JSON格式)
  15. * @property \Carbon\Carbon $created_at 创建时间
  16. * field end
  17. */
  18. class GameRewardLog extends ModelCore
  19. {
  20. /**
  21. * 与模型关联的表名
  22. *
  23. * @var string
  24. */
  25. protected $table = 'game_reward_logs';
  26. /**
  27. * 指示模型是否应该被打上时间戳
  28. * 由于这是日志表,只需要创建时间,不需要更新时间
  29. *
  30. * @var bool
  31. */
  32. public $timestamps = true;
  33. /**
  34. * 更新时间戳字段名
  35. * 设置为null表示不使用updated_at字段
  36. *
  37. * @var string|null
  38. */
  39. const UPDATED_AT = null;
  40. // attrlist start
  41. protected $fillable = [
  42. 'id',
  43. 'user_id',
  44. 'group_id',
  45. 'source_type',
  46. 'source_id',
  47. 'reward_items',
  48. ];
  49. // attrlist end
  50. /**
  51. * 应该被转换为原生类型的属性
  52. *
  53. * @var array
  54. */
  55. protected $casts = [
  56. 'user_id' => 'integer',
  57. 'group_id' => 'integer',
  58. 'source_id' => 'integer',
  59. 'reward_items' => 'json',
  60. ];
  61. /**
  62. * 获取奖励日志关联的奖励组
  63. *
  64. * @return BelongsTo
  65. */
  66. public function rewardGroup(): BelongsTo
  67. {
  68. return $this->belongsTo(GameRewardGroup::class, 'group_id', 'id');
  69. }
  70. }