PetSkill.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. namespace App\Module\Pet\Models;
  3. use UCore\ModelCore;
  4. use App\Module\Pet\Enums\PetStatus;
  5. use Illuminate\Database\Eloquent\Relations\HasMany;
  6. /**
  7. * 宠物技能模型
  8. *
  9. * field start
  10. * @property int $id
  11. * @property string $skill_name 技能名称
  12. * @property int $stamina_cost 体力消耗
  13. * @property int $cool_down 冷却时间(秒)
  14. * @property int $duration_time 持续时间(秒)
  15. * @property string $effect_desc 效果描述
  16. * @property int $min_level 最低等级要求
  17. * @property \Carbon\Carbon $created_at
  18. * @property \Carbon\Carbon $updated_at
  19. * field end
  20. */
  21. class PetSkill extends ModelCore
  22. {
  23. /**
  24. * 与模型关联的表名
  25. *
  26. * @var string
  27. */
  28. protected $table = 'pet_skills';
  29. /**
  30. * 可批量赋值的属性
  31. *
  32. * @var array
  33. */
  34. // attrlist start
  35. protected $fillable = [
  36. 'id',
  37. 'skill_name',
  38. 'stamina_cost',
  39. 'cool_down',
  40. 'duration_time',
  41. 'effect_desc',
  42. 'min_level',
  43. ];
  44. // attrlist end
  45. /**
  46. * 属性类型转换
  47. *
  48. * @var array
  49. */
  50. protected $casts = [
  51. 'stamina_cost' => 'integer',
  52. 'cool_down' => 'integer',
  53. 'min_level' => 'integer',
  54. 'created_at' => 'datetime',
  55. 'updated_at' => 'datetime',
  56. ];
  57. /**
  58. * 获取技能的使用记录
  59. *
  60. * @return HasMany
  61. */
  62. public function usageLogs(): HasMany
  63. {
  64. return $this->hasMany(PetSkillLog::class, 'skill_id');
  65. }
  66. }