GameRewardLog.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. 'created_at',
  49. ];
  50. // attrlist end
  51. /**
  52. * 应该被转换为原生类型的属性
  53. *
  54. * @var array
  55. */
  56. protected $casts = [
  57. 'user_id' => 'integer',
  58. 'group_id' => 'integer',
  59. 'source_id' => 'integer',
  60. 'reward_items' => 'json',
  61. ];
  62. /**
  63. * 获取奖励日志关联的奖励组
  64. *
  65. * @return BelongsTo
  66. */
  67. public function rewardGroup(): BelongsTo
  68. {
  69. return $this->belongsTo(GameRewardGroup::class, 'group_id', 'id');
  70. }
  71. }