| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- namespace App\Module\Farm\Models;
- use App\Module\GameItems\Models\Item;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
- /**
- * 种子产出配置模型
- *
- * @property int $id 主键ID
- * @property int $seed_id 种子ID
- * @property int $item_id 产出物品ID
- * @property int $min_amount 最小产出数量
- * @property int $max_amount 最大产出数量
- * @property float $probability 产出概率(0-100,如 10 表示 10%)
- * @property float $is_default 是否为默认产出
- * @property \Carbon\Carbon $created_at 创建时间
- * @property \Carbon\Carbon $updated_at 更新时间
- */
- class FarmSeedOutput extends Model
- {
- /**
- * 与模型关联的表名
- *
- * @var string
- */
- protected $table = 'farm_seed_outputs';
- /**
- * 可批量赋值的属性
- *
- * @var array
- */
- protected $fillable = [
- 'seed_id',
- 'item_id',
- 'min_amount',
- 'max_amount',
- 'probability',
- 'is_default',
- ];
- /**
- * 应该被转换为原生类型的属性
- *
- * @var array
- */
- protected $casts = [
- 'probability' => 'float',
- 'is_default' => 'boolean',
- ];
- /**
- * 获取关联的种子
- *
- * @return BelongsTo
- */
- public function seed(): BelongsTo
- {
- return $this->belongsTo(FarmSeed::class, 'seed_id', 'id');
- }
- // 物品关联
- public function item(): BelongsTo
- {
- return $this->belongsTo(Item::class, 'item_id', 'id');
- }
- }
|