mpociot / teamwork

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

memberofteam #81

Closed marksie1988 closed 4 years ago

marksie1988 commented 7 years ago

Is there a way that we can check if a user is a member of any team?

i have a dropdown menu that users can switch teams from, the problem i have is that if the user is not a member of a team it just displays a laravel error.

I created the following but it still errors or doesnt show the correct information:

@if(is_null(Auth::user()->teams))
                            Select Site
                        @else
                            @if(Auth::user()->currentTeam->name)
                                <i class="fa fa-users"></i> {{ Auth::user()->currentTeam->name }}
                            @else
                                Select Site
                            @endif
                        @endif
jlndk commented 7 years ago

If you have a teams relationship defined on your user model, you could do something like this

Auth::user()->teams->isNotEmpty()
okaufmann commented 4 years ago

I'll close this since its an old issue. Feel free to open another if you still need help.