| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- namespace App\Module\Farm\Models;
- use App\Module\Farm\Casts\FarmShrineDisplayAttributesCast;
- use App\Module\Farm\Casts\FarmShrineNumericAttributesCast;
- use App\Module\Farm\Enums\BUFF_TYPE;
- use UCore\ModelCore;
- /**
- * 神像配置模型
- * field start
- * @property int $id 主键ID
- * @property int $buff_type 神像类型:1丰收之神,2雨露之神,3屠草之神,4拭虫之神
- * @property string $name 神像名称
- * @property string $description 神像描述
- * @property int $duration_hours 默认持续时间(小时)
- * @property int $item_id 对应物品ID
- * @property \App\Module\Farm\Casts\FarmShrineDisplayAttributesCast $display_attributes 显示属性
- * @property \Carbon\Carbon $created_at 创建时间
- * @property \Carbon\Carbon $updated_at 更新时间
- * field end
- */
- class FarmShrineConfig extends ModelCore
- {
- /**
- * 与模型关联的表名
- *
- * @var string
- */
- protected $table = 'farm_shrine_configs';
- // attrlist start
- protected $fillable = [
- 'id',
- 'buff_type',
- 'name',
- 'description',
- 'duration_hours',
- 'item_id',
- 'display_attributes',
- ];
- // attrlist end
- /**
- * 应该被转换为原生类型的属性
- *
- * @var array
- */
- protected $casts = [
- 'buff_type' => 'integer',
- 'duration_hours' => 'integer',
- 'item_id' => 'integer',
- 'display_attributes' => FarmShrineDisplayAttributesCast::class,
- 'numeric_attributes' => FarmShrineNumericAttributesCast::class,
- ];
- /**
- * 获取神像类型名称
- *
- * @return string
- */
- public function getBuffTypeName(): string
- {
- return BUFF_TYPE::getName($this->buff_type);
- }
- /**
- * 获取神像效果描述
- *
- * @return string
- */
- public function getBuffDescription(): string
- {
- return BUFF_TYPE::getDescription($this->buff_type);
- }
- }
|