mpociot / teamwork

User to Team associations with invitation system for the Laravel 5 Framework
MIT License
1.07k stars 170 forks source link

Get teams that are not the currentTeam #85

Closed RobertCordes closed 4 years ago

RobertCordes commented 7 years ago

Is there a built-in way to get teams that are not the currentTeam? I've looked through the code and the issues but couldn't find anything. Right now I have my own solution:

# User.php

public function otherTeams()
{
    if (is_null($this->currentTeam)) return $this->teams;

    $otherTeams = $this->teams->reject(function ($team) {
        return $team->getKey() == $this->currentTeam->getKey();
    });

    return $otherTeams;
}

This seems to work, but if there's already a way to do this I obviously would use that 😄

Best regards, Robert

okaufmann commented 4 years ago

Unfortunately not. Maybe you'd like to create a PR?

RobertCordes commented 4 years ago

I don't even know which project I was working on at that time 🤔 But you’re right, it would’ve been a good idea to create a PR for that.