| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace App\Module\Shop\Models;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
- use UCore\ModelCore;
- use App\Module\GameItems\Models\Item;
- /**
- * 商店购买记录模型
- *
- * field start
- * field end
- */
- class ShopPurchaseLog extends ModelCore
- {
- /**
- * 与模型关联的表名
- *
- * @var string
- */
- protected $table = 'shop_purchase_logs';
- /**
- * 可批量赋值的属性
- *
- * @var array
- */
- protected $fillable = [
- 'user_id',
- 'shop_item_id',
- 'item_id',
- 'quantity',
- 'price',
- 'total_price',
- 'currency_id',
- 'purchase_time',
- 'ip_address',
- 'device_info',
- ];
- /**
- * 应该被转换为日期的属性
- *
- * @var array
- */
- protected $dates = [
- 'purchase_time',
- 'created_at',
- 'updated_at',
- ];
- /**
- * 获取关联的商品
- *
- * @return BelongsTo
- */
- public function shopItem(): BelongsTo
- {
- return $this->belongsTo(ShopItem::class, 'shop_item_id');
- }
- /**
- * 获取关联的物品
- *
- * @return BelongsTo
- */
- public function item(): BelongsTo
- {
- return $this->belongsTo(Item::class, 'item_id');
- }
- }
|