public function scopeForUserContext($query, Context $context)
    {
        if ($context->hasRole('Coach')) {
            return $query->whereHas('member', function ($query) use ($context) {
                /** @noinspection PhpUndefinedMethodInspection */
                $query->where('team_id', $context->team_id);
            });
        }
        return $query->where('inviter_id', $context->id);
    }
public function scopeForUserContext($query, Context $context)
    {
        if ($context->hasRole('Coach')) {
            return $query->whereHas('member', function ($query) use ($context) {
                /** @noinspection PhpUndefinedMethodInspection */
                $query->where('team_id', $context->team_id);
            });
        }
        return $query->where('inviter_id', $context->id);
    }
public function scopeForUserContext ( $ query , Context $ context ) { if ( $ context -> hasRole ( 'Coach' ) ) { return $ query -> whereHas ( 'member' , function ( $ query ) use ( $ context ) { /** @noinspection PhpUndefinedMethodInspection */ $ query -> where ( 'team_id' , $ context -> team_id ) ; } ) ; } return $ query -> where ( 'inviter_id' , $ context -> id ) ; }
Scope a query to only include MemberInvitations for a specified Team.

@param \Illuminate\Database\Eloquent\Builder $query
@param Context $context
@return \Illuminate\Database\Eloquent\Builder
Scope a query to only include MemberInvitations for a specified Team .