| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- namespace App\Module\Farm\Models;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Database\Eloquent\Relations\HasMany;
- /**
- * 种子配置模型
- * field start
- * @property int $id 主键ID
- * @property string $name 种子名称
- * @property int $type 种子类型:1普通,2神秘,3巨化
- * @property int $seed_time 种子期时间(秒)
- * @property int $sprout_time 发芽期时间(秒)
- * @property int $growth_time 成长期时间(秒)
- * @property int $mature_time 成熟期时间(秒,0表示无限)
- * @property int $wither_time 枯萎期时间(秒,0表示无限)
- * @property int $min_output 最小产出
- * @property int $max_output 最大产出
- * @property int $item_id 对应的物品ID
- * @property \App\Module\Farm\Casts\DisasterResistanceCast $disaster_resistance 灾害抵抗
- * @property \App\Module\Farm\Casts\DisplayAttributesCast $display_attributes 显示属性
- * @property \Carbon\Carbon $created_at 创建时间
- * @property \Carbon\Carbon $updated_at 更新时间
- * field end
- */
- class FarmSeed extends Model
- {
- /**
- * 与模型关联的表名
- *
- * @var string
- */
- protected $table = 'farm_seeds';
- /**
- * 可批量赋值的属性
- *
- * @var array
- */
- protected $fillable = [
- 'name',
- 'type',
- 'seed_time',
- 'min_output',
- 'max_output',
- 'item_id',
- 'disaster_resistance',
- 'display_attributes',
- ];
- /**
- * 应该被转换为原生类型的属性
- *
- * @var array
- */
- protected $casts = [
- 'disaster_resistance' => \App\Module\Farm\Casts\DisasterResistanceCast::class,
- 'display_attributes' => \App\Module\Farm\Casts\DisplayAttributesCast::class,
- ];
- /**
- * 获取种子的产出配置
- *
- * @return HasMany
- */
- public function outputs(): HasMany
- {
- return $this->hasMany(FarmSeedOutput::class, 'seed_id', 'id');
- }
- /**
- * 获取使用此种子的作物
- *
- * @return HasMany
- */
- public function crops(): HasMany
- {
- return $this->hasMany(FarmCrop::class, 'seed_id', 'id');
- }
- }
|