diff --git a/src/Models/User.php b/src/Models/User.php index 15fdd15..2f70ebd 100644 --- a/src/Models/User.php +++ b/src/Models/User.php @@ -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); } -} +} \ No newline at end of file