PromotionUserTalent.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. * field end
  11. */
  12. class PromotionUserTalent extends ModelCore
  13. {
  14. /**
  15. * 与模型关联的表名
  16. *
  17. * @var string
  18. */
  19. protected $table = 'promotion_user_talents';
  20. // attrlist start
  21. protected $fillable = [
  22. ];
  23. // attrlist end
  24. /**
  25. * 应该被转换为原生类型的属性
  26. *
  27. * @var array
  28. */
  29. protected $casts = [
  30. 'talent_level' => TALENT_LEVEL::class,
  31. ];
  32. /**
  33. * 获取用户信息
  34. *
  35. * @return BelongsTo
  36. */
  37. public function user()
  38. {
  39. return $this->belongsTo('App\Models\User', 'user_id');
  40. }
  41. /**
  42. * 获取达人等级配置
  43. *
  44. * @return BelongsTo
  45. */
  46. public function config()
  47. {
  48. return $this->belongsTo(PromotionTalentConfig::class, 'talent_level', 'level');
  49. }
  50. }