PromotionProfit.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace App\Module\Promotion\Models;
  3. use App\Module\Promotion\Enums\PROFIT_SOURCE_TYPE;
  4. use App\Module\Promotion\Enums\REFERRAL_LEVEL;
  5. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  6. use UCore\ModelCore;
  7. /**
  8. * 团队收益记录
  9. *
  10. * field start
  11. * field end
  12. */
  13. class PromotionProfit extends ModelCore
  14. {
  15. /**
  16. * 与模型关联的表名
  17. *
  18. * @var string
  19. */
  20. protected $table = 'promotion_profits';
  21. /**
  22. * 指示模型是否应该被打上时间戳
  23. *
  24. * @var bool
  25. */
  26. public $timestamps = false;
  27. // attrlist start
  28. protected $fillable = [
  29. ];
  30. // attrlist end
  31. /**
  32. * 应该被转换为原生类型的属性
  33. *
  34. * @var array
  35. */
  36. protected $casts = [
  37. 'profit_rate' => 'float',
  38. 'source_type' => PROFIT_SOURCE_TYPE::class,
  39. 'relation_type' => REFERRAL_LEVEL::class,
  40. ];
  41. /**
  42. * 获取收益用户信息
  43. *
  44. * @return BelongsTo
  45. */
  46. public function user()
  47. {
  48. return $this->belongsTo('App\Models\User', 'user_id');
  49. }
  50. /**
  51. * 获取团队成员信息
  52. *
  53. * @return BelongsTo
  54. */
  55. public function promotionMember()
  56. {
  57. return $this->belongsTo('App\Models\User', 'promotion_member_id');
  58. }
  59. /**
  60. * 获取物品信息
  61. *
  62. * @return BelongsTo
  63. */
  64. public function item()
  65. {
  66. return $this->belongsTo('App\Module\GameItems\Models\Item', 'item_id');
  67. }
  68. }