diff --git a/src/Mpociot/Teamwork/Traits/UserHasTeams.php b/src/Mpociot/Teamwork/Traits/UserHasTeams.php index b9a71f3..4ed7652 100644 --- a/src/Mpociot/Teamwork/Traits/UserHasTeams.php +++ b/src/Mpociot/Teamwork/Traits/UserHasTeams.php @@ -119,12 +119,10 @@ protected function retrieveTeamId( $team ) */ public function isOwnerOfTeam( $team ) { - $team = $this->retrieveTeamId( $team ); - $teamModel = Config::get( 'teamwork.team_model' ); - $teamKeyName = ( new $teamModel() )->getKeyName(); - return ( ( new $teamModel ) - ->where( "owner_id", "=", $this->getKey() ) - ->where( $teamKeyName, "=", $team )->first() + $team_id = $this->retrieveTeamId( $team ); + return ( $this->teams() + ->where('owner_id', $this->getKey()) + ->where('team_id', $team_id)->first() ) ? true : false; }