TeamUserTalent.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace App\Module\Promotion\Models;
  3. use App\Module\Promotion\Enums\TALENT_LEVEL;
  4. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  5. use UCore\ModelCore;
  6. /**
  7. * 达人等级
  8. *
  9. * field start
  10. * @property int $id 主键ID
  11. * @property int $user_id 用户ID
  12. * @property \App\Module\Promotion\Enums\TALENT_LEVEL $talent_level 达人等级:0无,1初级,2中级,3高级,4资深,5顶级
  13. * @property int $direct_count 直推人数
  14. * @property int $promotion_count 团队总人数
  15. * @property \Carbon\Carbon $created_at 创建时间
  16. * @property \Carbon\Carbon $updated_at 更新时间
  17. * field end
  18. */
  19. class PromotionUserTalent extends ModelCore
  20. {
  21. /**
  22. * 与模型关联的表名
  23. *
  24. * @var string
  25. */
  26. protected $table = 'promotion_user_talents';
  27. // attrlist start
  28. protected $fillable = [
  29. 'id',
  30. 'user_id',
  31. 'talent_level',
  32. 'direct_count',
  33. 'promotion_count',
  34. ];
  35. // attrlist end
  36. /**
  37. * 应该被转换为原生类型的属性
  38. *
  39. * @var array
  40. */
  41. protected $casts = [
  42. 'talent_level' => TALENT_LEVEL::class,
  43. ];
  44. /**
  45. * 获取用户信息
  46. *
  47. * @return BelongsTo
  48. */
  49. public function user()
  50. {
  51. return $this->belongsTo('App\Models\User', 'user_id');
  52. }
  53. /**
  54. * 获取达人等级配置
  55. *
  56. * @return BelongsTo
  57. */
  58. public function config()
  59. {
  60. return $this->belongsTo(PromotionTalentConfig::class, 'talent_level', 'level');
  61. }
  62. }