ItemGroup.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace App\Module\GameItems\Models;
  3. use Illuminate\Database\Eloquent\Relations\HasMany;
  4. use UCore\ModelCore;
  5. /**
  6. * 物品组
  7. *
  8. * field start
  9. * @property int $id 物品组ID,主键
  10. * @property string $name 物品组名称
  11. * @property string $code 物品组编码(唯一)
  12. * @property string $description 物品组描述
  13. * @property \Carbon\Carbon $created_at 创建时间
  14. * @property \Carbon\Carbon $updated_at 更新时间
  15. * field end
  16. */
  17. class ItemGroup extends ModelCore
  18. {
  19. /**
  20. * 与模型关联的表名
  21. *
  22. * @var string
  23. */
  24. protected $table = 'item_groups';
  25. // attrlist start
  26. protected $fillable = [
  27. 'id',
  28. 'name',
  29. 'code',
  30. 'description',
  31. ];
  32. // attrlist end
  33. /**
  34. * 获取物品组中的所有物品
  35. *
  36. * @return HasMany
  37. */
  38. public function groupItems(): HasMany
  39. {
  40. return $this->hasMany(ItemGroupItem::class, 'group_id','id');
  41. }
  42. /**
  43. * 获取物品组中的所有宝箱内容配置
  44. *
  45. * @return HasMany
  46. */
  47. public function chestContents(): HasMany
  48. {
  49. return $this->hasMany(ItemChestContent::class, 'group_id','id');
  50. }
  51. }