UserPart.php 781 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace app\common\model;
  3. use think\model\Pivot;
  4. class UserPart extends Pivot
  5. {
  6. // 设置字段信息
  7. protected $schema = [
  8. 'id' => 'int',
  9. 'puserid' => 'int',
  10. 'userid' => 'int',
  11. 'redmoney' => 'int',
  12. 'status' => 'tinyint',
  13. 'createtime' => 'int'
  14. ];
  15. // 设置字段自动转换类型
  16. protected $type = [
  17. 'createtime' => 'timestamp:Y-m-d H:i:s'
  18. ];
  19. public function getStatusTextAttr($value,$data)
  20. {
  21. $status = [1=>'未入职', 2=>'已入职', 3=>'已发放'];
  22. return $status[$data['status']];
  23. }
  24. // 关联User
  25. public function puser()
  26. {
  27. return $this->hasOne(User::class, "id", "puserid");
  28. }
  29. // 关联User
  30. public function user()
  31. {
  32. return $this->hasOne(User::class, "id", "userid");
  33. }
  34. }