12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- namespace addons\qingdongams\model;
- use think\Model;
- use traits\model\SoftDelete;
- /**
- * 团队表
- */
- class StaffTeam extends Model {
- // 表名,不含前缀
- protected $name = 'qingdongams_staff_team';
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- protected $deleteTime = 'deletetime';
- // 追加属性
- protected $append = [
- 'list_ids',
- ];
- public function getListIdsAttr()
- {
- $ids= StaffTeamList::where(['team_id'=>$this->id])->column('staff_id');
- return $ids?implode(',',$ids):'';
- }
- public function staff() {
- return $this->hasOne(Staff::class, 'id', 'staff_id')->field('id,name,img');
- }
- //获取审批人
- public function getFlowAttr($value){
- return json_decode($value,true);
- }
- //
- public function getCreatetimeAttr($value){
- return date('Y-m-d H:i:s',$value);
- }
- //团队业绩
- public function teamAchievement()
- {
- return $this->belongsTo(Achievement::class, 'id', 'obj_id')->where(['type' => 2]);
- }
- }
|