ShopPurchaseLog.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. * field end
  11. */
  12. class ShopPurchaseLog extends ModelCore
  13. {
  14. /**
  15. * 与模型关联的表名
  16. *
  17. * @var string
  18. */
  19. protected $table = 'shop_purchase_logs';
  20. /**
  21. * 可批量赋值的属性
  22. *
  23. * @var array
  24. */
  25. protected $fillable = [
  26. 'user_id',
  27. 'shop_item_id',
  28. 'item_id',
  29. 'quantity',
  30. 'price',
  31. 'total_price',
  32. 'currency_id',
  33. 'purchase_time',
  34. 'ip_address',
  35. 'device_info',
  36. ];
  37. /**
  38. * 应该被转换为日期的属性
  39. *
  40. * @var array
  41. */
  42. protected $dates = [
  43. 'purchase_time',
  44. 'created_at',
  45. 'updated_at',
  46. ];
  47. /**
  48. * 获取关联的商品
  49. *
  50. * @return BelongsTo
  51. */
  52. public function shopItem(): BelongsTo
  53. {
  54. return $this->belongsTo(ShopItem::class, 'shop_item_id');
  55. }
  56. /**
  57. * 获取关联的物品
  58. *
  59. * @return BelongsTo
  60. */
  61. public function item(): BelongsTo
  62. {
  63. return $this->belongsTo(Item::class, 'item_id');
  64. }
  65. }