| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- namespace App\Module\Farm\Models;
- use App\Module\GameItems\Models\Item;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
- /**
- * 种子产出配置模型
- * field start
- * @property int $id 主键ID
- * @property int $seed_id 种子ID
- * @property int $item_id 产出物品ID
- * @property int $min_amount 最小产出数量
- * @property int $max_amount 最大产出数量
- * @property int $disaster_min_amount 有灾害时最小产出数量
- * @property int $disaster_max_amount 有灾害时最大产出数量
- * @property float $probability 产出概率(0-1)
- * @property bool $is_default 是否为默认产出
- * @property \Carbon\Carbon $created_at 创建时间
- * @property \Carbon\Carbon $updated_at 更新时间
- * field end
- */
- class FarmSeedOutput extends Model
- {
- /**
- * 与模型关联的表名
- *
- * @var string
- */
- protected $table = 'farm_seed_outputs';
- /**
- * 可批量赋值的属性
- *
- * @var array
- */
- protected $fillable = [
- 'seed_id',
- 'item_id',
- 'min_amount',
- 'max_amount',
- 'disaster_max_amount',
- 'disaster_min_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');
- }
- }
|