| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace App\Module\GameItems\Models;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
- use UCore\ModelCore;
- /**
- * 物品组内容
- *
- * field start
- * @property int $id 记录ID,主键
- * @property int $group_id 物品组ID,外键关联kku_item_groups表
- * @property int $item_id 物品ID,外键关联kku_item_items表
- * @property float $weight 权重,决定从物品组中选择该物品的概率
- * @property \Carbon\Carbon $created_at 创建时间
- * @property \Carbon\Carbon $updated_at 更新时间
- * field end
- */
- class ItemGroupItem extends ModelCore
- {
- /**
- * 与模型关联的表名
- *
- * @var string
- */
- protected $table = 'item_group_items';
- // attrlist start
- protected $fillable = [
- 'id',
- 'group_id',
- 'item_id',
- 'weight',
- ];
- // attrlist end
- /**
- * 应该被转换为原生类型的属性
- *
- * @var array
- */
- protected $casts = [
- 'weight' => 'float',
- ];
- /**
- * 获取关联的物品组
- *
- * @return BelongsTo
- */
- public function group(): BelongsTo
- {
- return $this->belongsTo(ItemGroup::class, 'group_id');
- }
- /**
- * 获取关联的物品
- *
- * @return BelongsTo
- */
- public function item(): BelongsTo
- {
- return $this->belongsTo(Item::class, 'item_id');
- }
- }
|