Mpociot\Teamwork\Teamwork::hasPendingInvite PHP Method

hasPendingInvite() public method

Checks if the given email address has a pending invite for the provided Team
public hasPendingInvite ( $email, Team | array | integer $team ) : boolean
$email
$team Team | array | integer
return boolean
    public function hasPendingInvite($email, $team)
    {
        if (is_object($team)) {
            $team = $team->getKey();
        }
        if (is_array($team)) {
            $team = $team["id"];
        }
        return $this->app->make(Config::get('teamwork.invite_model'))->where('email', "=", $email)->where('team_id', "=", $team)->first() ? true : false;
    }

Usage Example

Example #1
0
 public function testHasPendingInviteFromArray()
 {
     /*
     |------------------------------------------------------------
     | Set
     |------------------------------------------------------------
     */
     $email = "*****@*****.**";
     $team_id = 1;
     $app = m::mock('App');
     $teamwork = new Teamwork($app);
     $team = ["id" => $team_id];
     $token = "asd";
     $inviteClass = 'Mpociot\\Teamwork\\TeamInvite';
     Config::shouldReceive('get')->once()->with('teamwork.invite_model')->andReturn($inviteClass);
     $teaminvite = m::mock($inviteClass);
     $app->shouldReceive('make')->with($inviteClass)->once()->andReturn($teaminvite);
     /*
     |------------------------------------------------------------
     | Expectation
     |------------------------------------------------------------
     */
     $teaminvite->shouldReceive('where')->once()->with('email', "=", $email)->andReturnSelf();
     $teaminvite->shouldReceive('where')->once()->with('team_id', "=", $team_id)->andReturnSelf();
     $teaminvite->shouldReceive('first')->once()->andReturnSelf();
     $this->assertTrue($teamwork->hasPendingInvite($email, $team));
 }
All Usage Examples Of Mpociot\Teamwork\Teamwork::hasPendingInvite