| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace App\Module\Pet\Models;
- use UCore\ModelCore;
- use App\Module\Pet\Casts\DisplayAttributesCast;
- use App\Module\Pet\Casts\NumericAttributesCast;
- /**
- * 宠物配置模型
- *
- * field start
- * @property int $id
- * @property string $pet_type 宠物类型
- * @property object|array $grade_probability 品阶概率配置
- * @property object|array $feed_effect 喂养效果配置
- * @property int $max_level 最大等级
- * @property int $stamina_recovery 体力恢复值/分钟
- * @property object|array $display_attributes 显示属性配置
- * @property object|array $numeric_attributes 数值属性配置
- * @property \Carbon\Carbon $created_at
- * @property \Carbon\Carbon $updated_at
- * field end
- */
- class PetConfig extends ModelCore
- {
- /**
- * 与模型关联的表名
- *
- * @var string
- */
- protected $table = 'pet_configs';
- // attrlist start
- protected $fillable = [
- 'id',
- 'pet_type',
- 'grade_probability',
- 'feed_effect',
- 'max_level',
- 'stamina_recovery',
- 'display_attributes',
- 'numeric_attributes',
- ];
- // attrlist end
- /**
- * 应该被转换为原生类型的属性
- *
- * @var array
- */
- protected $casts = [
- 'grade_probability' => 'json',
- 'feed_effect' => 'json',
- 'max_level' => 'integer',
- 'stamina_recovery' => 'integer',
- 'display_attributes' => DisplayAttributesCast::class,
- 'numeric_attributes' => NumericAttributesCast::class,
- ];
- /**
- * 获取指定宠物类型的配置
- *
- * @param string $petType
- * @return self|null
- */
- public static function getByType(string $petType): ?self
- {
- return self::where('pet_type', $petType)->first();
- }
- }
|