StaffTeam.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace addons\qingdongams\model;
  3. use think\Model;
  4. use traits\model\SoftDelete;
  5. /**
  6. * 团队表
  7. */
  8. class StaffTeam extends Model {
  9. // 表名,不含前缀
  10. protected $name = 'qingdongams_staff_team';
  11. // 自动写入时间戳字段
  12. protected $autoWriteTimestamp = 'int';
  13. // 定义时间戳字段名
  14. protected $createTime = 'createtime';
  15. protected $updateTime = 'updatetime';
  16. protected $deleteTime = 'deletetime';
  17. // 追加属性
  18. protected $append = [
  19. 'list_ids',
  20. ];
  21. public function getListIdsAttr()
  22. {
  23. $ids= StaffTeamList::where(['team_id'=>$this->id])->column('staff_id');
  24. return $ids?implode(',',$ids):'';
  25. }
  26. public function staff() {
  27. return $this->hasOne(Staff::class, 'id', 'staff_id')->field('id,name,img');
  28. }
  29. //获取审批人
  30. public function getFlowAttr($value){
  31. return json_decode($value,true);
  32. }
  33. //
  34. public function getCreatetimeAttr($value){
  35. return date('Y-m-d H:i:s',$value);
  36. }
  37. //团队业绩
  38. public function teamAchievement()
  39. {
  40. return $this->belongsTo(Achievement::class, 'id', 'obj_id')->where(['type' => 2]);
  41. }
  42. }