FarmSeedOutput.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace App\Module\Farm\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  5. /**
  6. * 种子产出配置模型
  7. *
  8. * @property int $id 主键ID
  9. * @property int $seed_id 种子ID
  10. * @property int $item_id 产出物品ID
  11. * @property int $min_amount 最小产出数量
  12. * @property int $max_amount 最大产出数量
  13. * @property float $probability 产出概率(0-1)
  14. * @property bool $is_default 是否为默认产出
  15. * @property \Carbon\Carbon $created_at 创建时间
  16. * @property \Carbon\Carbon $updated_at 更新时间
  17. */
  18. class FarmSeedOutput extends Model
  19. {
  20. /**
  21. * 与模型关联的表名
  22. *
  23. * @var string
  24. */
  25. protected $table = 'farm_seed_outputs';
  26. /**
  27. * 可批量赋值的属性
  28. *
  29. * @var array
  30. */
  31. protected $fillable = [
  32. 'seed_id',
  33. 'item_id',
  34. 'min_amount',
  35. 'max_amount',
  36. 'probability',
  37. 'is_default',
  38. ];
  39. /**
  40. * 应该被转换为原生类型的属性
  41. *
  42. * @var array
  43. */
  44. protected $casts = [
  45. 'probability' => 'float',
  46. 'is_default' => 'boolean',
  47. ];
  48. /**
  49. * 获取关联的种子
  50. *
  51. * @return BelongsTo
  52. */
  53. public function seed(): BelongsTo
  54. {
  55. return $this->belongsTo(FarmSeed::class, 'seed_id', 'id');
  56. }
  57. }