ShopPurchaseLog.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace App\Module\Shop\Models;
  3. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  4. use UCore\ModelCore;
  5. use App\Module\GameItems\Models\Item;
  6. /**
  7. * 商店购买记录模型
  8. *
  9. * field start
  10. * @property int $id 记录ID,主键
  11. * @property int $user_id 用户ID
  12. * @property int $shop_item_id 商品ID,外键关联kku_shop_items表
  13. * @property int $item_id 物品ID,外键关联kku_item_items表(新版本使用奖励组,此字段可为空)
  14. * @property int $quantity 购买数量
  15. * @property int $price 单价
  16. * @property int $total_price 总价
  17. * @property int $currency_id 货币类型ID(新版本使用消耗组,此字段可为空)
  18. * @property string $purchase_time 购买时间
  19. * @property string $ip_address 购买IP地址
  20. * @property string $device_info 设备信息
  21. * @property \Carbon\Carbon $created_at 创建时间
  22. * @property \Carbon\Carbon $updated_at 更新时间
  23. * field end
  24. */
  25. class ShopPurchaseLog extends ModelCore
  26. {
  27. /**
  28. * 与模型关联的表名
  29. *
  30. * @var string
  31. */
  32. protected $table = 'shop_purchase_logs';
  33. /**
  34. * 可批量赋值的属性
  35. *
  36. * @var array
  37. */
  38. protected $fillable = [
  39. 'user_id',
  40. 'shop_item_id',
  41. 'item_id',
  42. 'quantity',
  43. 'price',
  44. 'total_price',
  45. 'currency_id',
  46. 'purchase_time',
  47. 'ip_address',
  48. 'device_info',
  49. ];
  50. /**
  51. * 应该被转换为日期的属性
  52. *
  53. * @var array
  54. */
  55. protected $dates = [
  56. 'purchase_time',
  57. 'created_at',
  58. 'updated_at',
  59. ];
  60. /**
  61. * 获取关联的商品
  62. *
  63. * @return BelongsTo
  64. */
  65. public function shopItem(): BelongsTo
  66. {
  67. return $this->belongsTo(ShopItem::class, 'shop_item_id');
  68. }
  69. /**
  70. * 获取关联的物品
  71. *
  72. * @return BelongsTo
  73. */
  74. public function item(): BelongsTo
  75. {
  76. return $this->belongsTo(Item::class, 'item_id');
  77. }
  78. }