Complete Teams Feature in Laravel 13 using Livewire
Chapters8
The user is registered and a personal team is automatically created for that user, with navigation to the team dashboard.
Laravel 13’s Teams feature in the official starter kit works out of the box with Livewire, auto-creating a personal team and supporting invites, roles, and settings management.
Summary
Tony Xhepa walks through the Laravel 13 starter kit's Teams feature powered by Livewire, showing how a new user automatically gets a personal team upon registration. The video demonstrates team creation, editing, and deletion rules, including that personal teams cannot be deleted. You’ll see how the UI lets you switch between teams via a slug-based dashboard route and how the settings area exposes Profile, Security, Appearance, and a dedicated Teams management page. Tony also covers inviting members, assigning roles (member or admin), and how invitations are tracked with a dedicated table and acceptance flow that ties to the user’s login state. The code reveals relationships like Team hasMany Members and belongsTo User, plus the Invitation model with a unique code used in the invitation URLs. You’ll also learn about the route structure, such as the current_team middleware and the invitation acceptance logic, and how team slug generation works when teams are created or renamed. Finally, Tony notes practical quirks, like the need to log in with the invited email to accept invitations and how public routes reflect ownership versus membership. If you’re building multi-tenant features in Laravel, this walkthrough clarifies how to wire models, migrations, and Livewire components together in a real-world example.
Key Takeaways
- A new Laravel user automatically receives a personal team on registration, with the personal flag set and a dedicated slug.
- Teams are managed via a slug-based dashboard route (example-1/dashboard) powered by current_team middleware and verified invitations.
- Invitations are created with a role (member or admin), stored in a team_invitations table, and require the invitee to log in with the matching email to accept.
- The system supports creating additional teams, editing team names, inviting members, and setting owner vs. member roles, with personal teams restricted from deletion.
- Team relationships include Team hasMany Members, Membership contains team_id, user_id, and role, and Invitations tie to both team and inviting user.
- Invitations include a unique 64-character code used in URLs to accept or verify access, with validation checks for email matching and expiration.
- Code structure highlights include routes grouped under a current_team prefix, a Dashboard route per team, and models for User, Team, Membership, and Invitation with clear relationships and access controls.
Who Is This For?
Essential viewing for Laravel developers implementing multi-tenant teams in the starter kit or building admin dashboards with Livewire, showing practical patterns for teams, invitations, and role-based access.
Notable Quotes
""When we register here for the first time, it's going to create also a team for the user. So let's create the user... and here is the team created for this user.""
—Shows automatic creation of a personal team on user registration.
""We can edit only the name of this team and also we can invite members numbers on this.""
—Illustrates editing and inviting members on a team.
""This is personal we can only edit the name. But this one which we created we can delete also.""
—Demonstrates deletion rules distinguishing personal vs. non-personal teams.
""The invitation code is going to invitation code string random 64.""
—Details how invitation codes are generated for secure access.
""You may think why we have example-1 dashboard... because we created the team with name example but we have two teams with example.""
—Explains slug-based routing and automatic suffixing for duplicate team names.
Questions This Video Answers
- How do I automatically create a personal team on Laravel user registration?
- How does Laravel 13 starter kit handle team invitations and roles?
- What routes and middleware govern the current team in Laravel Livewire apps?
- How are team slugs generated and updated in Laravel multiple-team apps?
- Can personal teams be deleted in Laravel Teams feature and who can manage team members?
Laravel 13Laravel Starter KitsLaravel LivewireTeams featureTeam invitationsRole-based accessRouting and middlewareEloquent relationships invitations flow
Full Transcript
Hello friends, Sony here. Welcome. In this video, I want to test the teams feature which comes with the Laravel starter kits. I have created a project with Laravel and live wire starter kit and I have chosen to have the themes. And here is the project I named themes and I have open here themes. When we register here for the first time, it's going to create also a team for the user. So let's create the user. Okay, here is the user and also here is the team created for this user. Now this team is created automatically when the user is created which mean this is a personal team and as you can see also we don't navigate slash team uh dashboard but slash the team slug and the dashboard SL dashboard.
Okay, we can select teams here. We have only one right now. We can create new team with this model just the team name and we can create or we have the option to go to settings and here we have the profile security and appearance and also we have teams and here we is going to list all our teams as you can see this team is personal we are owner of this team and we can edit this team we can edit only the name of this team and also we can invite members numbers on this. Also, we can create a new team.
So, I go back, create a new team, the same model here, and create new team. So, let's create an example team. Okay. Now, we are on the example. We can edit the name of this team. We can invite members also. Here we are as a owner. As you can see, we can delete this team. Now if I go back and just see this is personal. As you can see we have a badge just say this is personal. If I click because this is personal we can only edit the name. We cannot delete this team. But this one which we created we can delete also.
We can edit the name and we can invite members. Now let's say I want to invite member. I'm going to add a random email. So test one and I'm going to say example.com and I'm going to copy this email. And here we have also the role when we invite the member to the team. So it's going to be a role as member or as admin. I'm going to create this as a member and I'm going to send invitation. Okay. So pending invitations here and I have my strap here but just let me open the terminal and run the composer around dev here.
Okay. And here we have team invitation one is done. Here's the email and we have the email to accept the invitation. Now if I copy this or let's copy this link here which is the same and I'm going to open in a new browser. Here is the browser. Let's paste it here. We are not logged in. And if I hit enter, yeah, we need to register first on this project and then we can accept that invitation. But what if I register with the new email, not with that email I sent I created that invitation. Okay.
So here we have this email. So let's go and register with big filler which has this email. If I get create the account we are on the slash invitation slash the code here and also slash accept. If I click yeah we have only this team which is the personal team of this user. If I go settings themes, yeah, we have only the personal and again if I come here and just copy that link and we are logged in. So if I just paste that link and hit again, nothing is changed. Okay, so it's going to be accepted only if we are logged in with this email.
So now let's go and log out here and I'm going to register with this email now. So I'm going to copy the email here and paste that email and I want to say the password is yeah I'm going to just add password like this and create the account. Now we have the personal team. Okay. And now let's go and copy the link. And if I paste the link now here and hit enter. Now we return to example one dashboard. So now we have also the example and personal team. If I click the example or if I go to settings teams, we have this personal team and also we have the example.
And because we are member, we just can view the team. Nothing else. We can view the team. So team members is this one and also this one. This one is owner and this one is member. If I go here and now it's saying pending invitation. But if I refresh, yeah, we have two team members and we can change this is very good. We can change from here the role for this one. Right now is member but if I say admin. Okay. And now come here and refresh. Now we can update the because we are owner admin.
We can update the name and also we can invite members here and so on. Also let me just show you the in the table class we have the users. The user has the name email mail verified and the password remember token created at updated at true factor secrets and true factor recovery codes true factor confirmed at and also the quent team ID quent team ID. So for example, the first user has the team ID one. The second user has the current team ID three, four, six, 7. Also this one, the user with the James has the current team with ID six.
If I go to teams, the ID6 is for the example. Okay. So the example is for the this one and also James which mean if I come here we have Dylan here and also James which is in this browser we have teams now teams has a name slack and is personal by default when we create as I told you when we create the user it's going to automatically create also a personal team And it's going to set also is personal to one. Then we have team members. Here we have team ID and the user ID and also the role.
So for example for the team ID six we have the user ID four which is the owner and then team ID six. The user ID six is admin. Okay. Then we have a team invitation and we have only one with ID called team ID 6. the email role member. We created that with the role member and invited by the user with ID for expires at and accepted that. Okay. And of course, we can open also the code. For example, if you go Yeah, you can see many things here. But if you go to routes, we have web route and we have the welcome default.
And then we have the current team route prefix with quant team middleware out and verified. And then we have group and the one route that we have here which is the dashboard. Okay. So we have current team. So for example example uh let me just show you. So if I go to dashboard we have example- one and then dashboard. And you may think why we have example- one because we created the team with name example but we have two teams with example. Okay. So name is example here and also this one is example and because the first one has the slack example the second team with example name has example- one automatically.
Okay. Next we have this uh route middleware out and live wire invitation pass in the invitation code and accept. And if we go here, yeah, we have amount invitation, invitation, this invitation assign it to this invitation here and then this accept invitation which first we get the user and we got that user without user and it's going to validate the invitation passing the user and this invitation which mean here we have that user and team invitation. It's going to check if invitation is accepted. It's going to throw the valid validation exception. Invitation this invitation has already been accepted.
Next we have if invitation is expired. Invitation this invitation has expired. And also if str invitation email is not as user email is going to throw the validation exception with message invitation. this invitation was sent to a different email address. Okay. Also, if you go to settings here, we have the settings, settings, profile, appearance and security. And then we have this settings teams and also settings teams team here. So if I go to this one settings, teams. Yeah, we have to create the team validate the name and then team create team handle the out user and pass in the validated name also this pass to close the model and reset the name and then redirect to the route teams edit.
Now let's see on the app we have models and we have the user we have class initials nothing else we have we have membership here membership vable team ID user ID and the role table is team members and we have a relationship team which is belongs to and also the user belongs to the team has the name slag is personal parent boot and static created. If empty team slag is going to say team slug static generate unique team slug pass in the team name and also on updating on updating his if team is dirty name team slack generate unique team slug also the we have a owner method to get the team owner and the members belongs to many.
So this belongs to many user team members team ID user ID using the membership class membership has many and also invitation has many has many team invitation class and get the route key name using slack here team invitation team ID email ro invited by expires at and accepted at boot creating if empty The invitation code is going to invitation code string random 64. And then we have a team belongs to relationship inviter belongs to to the user and is accepted boolean is going to return this accepted at not null is pending if this accepted at lab with null and not this expire is expired and is expired on boolean.
So this expires at not null and this expires at is passed cast and the get route key name which is the code and yeah that's it all about the themes we have in LA starter kits. If you like more about this you just drop a comment on this YouTube video and I will create another video of what you like. And that's it all about this video what I wanted to show you. Now don't forget to subscribe to my channel, like the video, share with your friends and see you in the next one. All the best.
Thank you very much.
More from Tony Xhepa
Get daily recaps from
Tony Xhepa
AI-powered summaries delivered to your inbox. Save hours every week while staying fully informed.






