FarmTeamProfit.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace App\Module\Farm\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  5. /**
  6. * 团队收益记录模型
  7. * field start
  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. * field end
  16. */
  17. class FarmTeamProfit extends Model
  18. {
  19. /**
  20. * 与模型关联的表名
  21. *
  22. * @var string
  23. */
  24. protected $table = 'farm_team_profits';
  25. /**
  26. * 可批量赋值的属性
  27. *
  28. * @var array
  29. */
  30. protected $fillable = [
  31. 'user_id',
  32. 'team_member_id',
  33. 'harvest_id',
  34. 'profit_amount',
  35. 'profit_rate',
  36. ];
  37. /**
  38. * 应该被转换为原生类型的属性
  39. *
  40. * @var array
  41. */
  42. protected $casts = [
  43. 'profit_rate' => 'float',
  44. ];
  45. /**
  46. * 表明模型是否应该被打上时间戳
  47. *
  48. * @var bool
  49. */
  50. public $timestamps = false;
  51. /**
  52. * 获取关联的收获记录
  53. *
  54. * @return BelongsTo
  55. */
  56. public function harvestLog(): BelongsTo
  57. {
  58. return $this->belongsTo(FarmHarvestLog::class, 'harvest_id', 'id');
  59. }
  60. }