FarmTeamProfit.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 $user_id 获得收益的用户ID
  10. * @property int $team_member_id 团队成员ID
  11. * @property int $harvest_id 收获记录ID
  12. * @property int $profit_amount 分成收益数量
  13. * @property float $profit_rate 分成比例
  14. * @property \Carbon\Carbon $created_at 创建时间
  15. */
  16. class FarmTeamProfit extends Model
  17. {
  18. /**
  19. * 与模型关联的表名
  20. *
  21. * @var string
  22. */
  23. protected $table = 'farm_team_profits';
  24. /**
  25. * 可批量赋值的属性
  26. *
  27. * @var array
  28. */
  29. protected $fillable = [
  30. 'user_id',
  31. 'team_member_id',
  32. 'harvest_id',
  33. 'profit_amount',
  34. 'profit_rate',
  35. ];
  36. /**
  37. * 应该被转换为原生类型的属性
  38. *
  39. * @var array
  40. */
  41. protected $casts = [
  42. 'profit_rate' => 'float',
  43. ];
  44. /**
  45. * 表明模型是否应该被打上时间戳
  46. *
  47. * @var bool
  48. */
  49. public $timestamps = false;
  50. /**
  51. * 获取关联的收获记录
  52. *
  53. * @return BelongsTo
  54. */
  55. public function harvestLog(): BelongsTo
  56. {
  57. return $this->belongsTo(FarmHarvestLog::class, 'harvest_id', 'id');
  58. }
  59. }