Skip to main content
Pricing Community Docs Get Started GitHub My Account
Community
Search
Log In
Log In Sign Up
J

James Pence

Joined Dec 11, 2024 Last seen Jul 2, 2025
Posts 4 Comments 3

⁨James Pence⁩'s Comments

Newest Top
Newest Top
    1. ❓ Support
    2. Seemless Laravel (11) user integration
    Answer
    J James Pence Dec 19, 2024
    In reply to G Gabriel Silva
    G Gabriel Silva Dec 19, 2024
    Looks good. Could you share your code?

    I created a simplified pair of models in my namespace WaterholeUser and WaterholeRole. they correspond to User and Group within waterhole.
    I also have permissions of "forum_use", and "forum_manage" assigned to roles in the main app.

    // in base application User.php
     public function toWaterholeUser(): ?PendingUser
            {
                if( $this->email ){
                    // Check if the user already exists in Waterhole.dev
                    $waterholeUser = WaterholeUser::getUserByEmail( $this->email );
                    if( !$waterholeUser ){
                        // Create a new Waterhole.dev user account
                        $waterholeUser = WaterholeUser::createDefaultUser( [
                                                                               'email'    => $this->email,
                                                                               'username' => $this->getFullnameAttribute(),
                                                                           ] );
                        // Update the Waterhole.dev user's roles to match the Laravel user's roles
                        $role_ids=[];
                        if( $this->hasPermissionTo( 'forum_use' ) ){
                            $role_ids[] =[ WaterholeRole::where( 'name', 'Member' )->first()->id ];
                        }else if( $this->hasPermissionTo( 'forum_manage' ) ){
                            $role_ids[] = WaterholeRole::where( 'name','Admin')->first()->id;
                        }else {
                            $role_ids[] = WaterholeRole::where( 'name','Guest')->first()->id;
                        }
    
                        $waterholeUser->roles()->sync( $role_ids );
                    }
                }
    
                return new PendingUser(
                    identifier: $this->getAuthIdentifier(),
                    email: $this->email,
                    name: $this->getFullnameAttribute()
                );
        }
    1 Show ⁨1⁩ ⁨reply⁩
    Reply Actions
    1. ❓ Support
    2. Seemless Laravel (11) user integration
    J James Pence Dec 17, 2024

    The solution I came to was checking in the toWaterholeUser function before returning the PendingUser. If there is no waterholeUser then I add the waterholeUser with the proper roles based on the permissions from the regular application's "spatie/laravel-permission" system.

    1 Show ⁨1⁩ ⁨reply⁩
    Reply Actions
    1. ❓ Support
    2. Seemless Laravel (11) user integration
    J James Pence Dec 12, 2024
    In reply to G Gabriel Silva
    G Gabriel Silva Dec 12, 2024
    Hi @James Pence, Have you closely followed the integration docs for authentication? It seems it gets you covered here: https://waterhole.dev/docs/main/laravel#authentication Cheers,

    I did and the toWaterholeUser function is getting the values to populate the form, but the form is still showing and expecting the Create Account submission button to be pressed to actually add the user to the waterhole users table.

    1 Show ⁨1⁩ ⁨reply⁩
    Reply Actions
© 2025 Waterhole Pty Ltd
  • Product
    • Pricing
    • Releases
    • Roadmap
    • Demo
  • Resources
    • Documentation
    • Support
    • Experts
    • Blog
  • Community
    • Community
    • Twitter
    • GitHub
  • Company
    • Terms & Privacy
    • Software License