| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- namespace App\Module\Shop\Models;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
- use UCore\ModelCore;
- use App\Module\GameItems\Models\Item;
- /**
- * 商店购买记录模型
- *
- * field start
- * @property int $id 记录ID,主键
- * @property int $user_id 用户ID
- * @property int $shop_item_id 商品ID,外键关联kku_shop_items表
- * @property int $item_id 物品ID,外键关联kku_item_items表
- * @property int $quantity 购买数量
- * @property int $price 单价
- * @property int $total_price 总价
- * @property int $currency_id 货币类型ID
- * @property string $purchase_time 购买时间
- * @property string $ip_address 购买IP地址
- * @property string $device_info 设备信息
- * @property \Carbon\Carbon $created_at 创建时间
- * @property \Carbon\Carbon $updated_at 更新时间
- * 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');
- }
- }
|