Change to how we resolve a user's team between Slack/ and App/* models

This commit is contained in:
Deon George 2022-02-24 13:56:47 +11:00
parent c5a13046ed
commit 1c3966598d
1 changed files with 8 additions and 3 deletions

View File

@ -21,6 +21,11 @@ class User extends Model
return $this->belongsTo(Enterprise::class);
}
public function team()
{
return $this->belongsTo(Team::class);
}
/* ATTRIBUTES */
/**
@ -49,10 +54,10 @@ class User extends Model
*
* @return mixed
*/
public function getTeamAttribute(): ?Team
public function getUserTeamAttribute(): ?Team
{
Log::debug(sprintf('%s:User [%s]',self::LOGKEY,$this->id),['team'=>$this->team_id,'enterprise'=>$this->enterprise_id,'eo'=>$this->enterprise]);
return $this->team_id ? Team::find($this->team_id) : (($x=$this->enterprise->teams) ? $x->first() : NULL);
return $this->team_id ? $this->team : (($x=$this->enterprise->teams) ? $x->first() : NULL);
}
}
}