Skip to content
Discussion options

You must be logged in to vote

I think my main issue is how I've implemented a method to return the users roles for a given team (ie what roles have been assigned to the user for the given team).

Is there a cleaner way to do this?

/**
     * Returns the Roles associated with the current user for the given team
     *
     * @param  User  $user
     * @param  int  $teamId
     * @return Collection|mixed|Role[]
     */
    public function getTeamRoles(self $user, int $teamId)
    {
        $originalTeam = app(PermissionRegistrar::class)->getPermissionsTeamId();
        app(PermissionRegistrar::class)->setPermissionsTeamId($teamId);

        $user->load('roles');

        setPermissionsTeamId($originalTeam);

        return 

Replies: 3 comments 18 replies

Comment options

You must be logged in to vote
11 replies
@erikn69
Comment options

@mojowill
Comment options

@erikn69
Comment options

@mojowill
Comment options

@erikn69
Comment options

Comment options

You must be logged in to vote
4 replies
@erikn69
Comment options

@mojowill
Comment options

@erikn69
Comment options

@mojowill
Comment options

Comment options

You must be logged in to vote
3 replies
@erikn69
Comment options

@mojowill
Comment options

@erikn69
Comment options

Answer selected by mojowill
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants