| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- namespace App\Module\GameItems\Models;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
- use UCore\ModelCore;
- /**
- * 合成配方材料
- *
- * field start
- * @property int $id 记录ID,主键
- * @property int $recipe_id 配方ID,外键关联kku_item_recipes表
- * @property int $item_id 材料物品ID,外键关联kku_item_items表
- * @property int $quantity 所需数量
- * @property int $is_consumed 是否消耗(0:不消耗, 1:消耗)
- * @property \Carbon\Carbon $created_at 创建时间
- * @property \Carbon\Carbon $updated_at 更新时间
- * field end
- */
- class ItemRecipeMaterial extends ModelCore
- {
- /**
- * 与模型关联的表名
- *
- * @var string
- */
- protected $table = 'item_recipe_materials';
- // attrlist start
- protected $fillable = [
- 'id',
- 'recipe_id',
- 'item_id',
- 'quantity',
- 'is_consumed',
- ];
- // attrlist end
- /**
- * 应该被转换为原生类型的属性
- *
- * @var array
- */
- protected $casts = [
- 'quantity' => 'integer',
- 'is_consumed' => 'boolean',
- ];
- /**
- * 获取关联的配方
- *
- * @return BelongsTo
- */
- public function recipe(): BelongsTo
- {
- return $this->belongsTo(ItemRecipe::class, 'recipe_id');
- }
- /**
- * 获取关联的物品
- *
- * @return BelongsTo
- */
- public function item(): BelongsTo
- {
- return $this->belongsTo(Item::class, 'item_id');
- }
- }
|