Skip to content

Instantly share code, notes, and snippets.

@dillinghamio
Last active August 13, 2019 13:55
Show Gist options
  • Save dillinghamio/0a78200dd8d5a11f45aeda049eb1d2f9 to your computer and use it in GitHub Desktop.
Save dillinghamio/0a78200dd8d5a11f45aeda049eb1d2f9 to your computer and use it in GitHub Desktop.
currentTeamMembersByRole

User's Fellow Members in Laravel Spark

add to your user model

public function teamMembers($role='member')
{
    return $this->currentTeam
        ->users()
        ->wherePivot('role', $role)
        ->get();
}

Usage

$fellowMembers = auth()->user()->teamMembers();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment