From 0c5e6a43399698e4dc09b0adb45a3b977e9a8607 Mon Sep 17 00:00:00 2001 From: Michael Pivonka Date: Sat, 19 Nov 2016 07:52:22 -0500 Subject: [PATCH] Changed isOwnerOfTeam to use $user->team() (#68) * Checked isOwnerOfTeam to use ->team() * Fixed isOwnerOfTeam return values * Forgot to ->first() in isOwnerOfTeam() --- src/Mpociot/Teamwork/Traits/UserHasTeams.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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; }