Playing
01. Introduction and demo

Episodes

0%
Your progress
  • Total: 4h 36m
  • Played: 0m
  • Remaining: 4h 36m
Join or sign in to track your progress
01. Introduction and demo
4m 49s
0%
02. Setup with Pest
4m 2s
0%
03. Building the user teams relations
6m 5s
0%
04. Creating a personal team when registering
6m 3s
0%
05. Leaving all teams when an account is deleted
3m 55s
0%
06. Tracking the current team
4m 50s
0%
07. Showing team details in the UI
2m 55s
0%
08. Switching to another team
7m 24s
0%
09. Authorising team switching
6m 53s
0%
10. Updating a team name
10m 48s
0%
11. Basic roles and permissions setup
5m 26s
0%
12. Team roles and permissions middleware
9m 18s
0%
13. Authorising current team updates
3m 43s
0%
14. Testing team permissions through HTTP requests
3m 58s
0%
15. Leaving a team
10m 50s
0%
16. Displaying team members
8m 42s
0%
17. Making team members look better
5m 3s
0%
18. Removing a team member
15m 18s
0%
19. Preventing self removal from a team
4m 7s
0%
20. Storing invitations
13m 31s
0%
21. Validating invitations
6m 38s
0%
22. Authorising team invitation creation
6m 22s
0%
23. Displaying invitations
3m 16s
0%
24. Revoking invitations
12m 46s
0%
25. Sending an invitation email
13m 6s
0%
26. Accepting an invitation
12m 22s
0%
27. Displaying a modal to change a member’s role
10m 31s
0%
28. Updating a member’s role
9m 5s
0%
29. More authorisation and checks for role changing
10m 14s
0%
30. Fixing up the email sending test details
49s
0%
31. Fixing and validating email addresses for invites
1m 32s
0%
32. Tidying up @can directive checks
3m 25s
0%
33. Detaching roles when removing users
5m
0%
34. Adding an extra layer of protection to the team middleware
6m 35s
0%
35. Getting related models through teams
5m 37s
0%
36. Building a helper to access the current team
10m 47s
0%
37. Getting all related models through all teams
7m 15s
0%
38. Creating new teams
13m 7s
0%

Transcript

00:00
Building team functionality with roles and permissions is probably up there with one of the more tricky things to manage in Laravel. Well I'm going to take you through this course and simplify this down as much as possible and give you a really good base
00:13
to start your next project on if you're working with teams, roles and permissions. Let's go ahead and look at what we're going to cover. We will be adding a little bit more to the course so you might find that there are some additional features
00:26
that I don't cover here but let's go through the entire process. Let's go ahead and sign up with a account and let's see what happens when we first create an account within this system. Okay so we've got the standard stuff that we would see in Laravel Breeze, the ability to update our
00:41
profile stuff but now we have this team drop down. So this will list out all of the teams that we currently belong to. At the moment we belong to a personal team. It's a good idea to start with personal teams and then when you start to create new teams and add more people you can go ahead
00:57
and just delete out your personal team. It just makes the entire system work a lot better. Okay let's head over to team settings. This is where most of this happens. Now behind the scenes all of this is check with roles and permissions. So if I didn't have
01:09
the ability to update the team name for example I wouldn't see this but because I am the team admin of this and I'm the only member I can pretty much do anything I want here. Okay so we can obviously go ahead and update the team name. That's pretty straightforward.
01:24
We can also list and manage all of our users. So there are a couple of other options here. Let's go ahead and invite another member and see what this process looks like and then we'll go ahead and see it from their end as well. Okay so I'm going to enter an email
01:39
address and hit invite. That's going to go ahead and add a pending invitation for that user which I can go ahead and revoke if I need to. Let's hop over to our email client and you can see here that this has been sent to that email address and it says
01:51
you've been invited to Alex's team. Now this user doesn't have an account at the moment. It doesn't matter what email address that we enter here. Whether they have an account or not does not matter. What we can do is go through to accept the invite
02:05
and then we can go ahead and register an account. So just before I accept this invite let's go ahead and register an account with this email. Again the email that's used doesn't matter here. We're trying to make this as flexible as possible and let's go over to
02:19
our email client and we'll just copy this link rather than having this open for us and just go ahead and paste it in here. Okay so now that I've done that we have now been accepted into this team and you can see that I can click on this team and I can see any information about it.
02:33
So I'm within this team at the moment. Let's go over to the team settings and you can see here this looks a little bit different. So we don't have an ability as a team member to do things like update the team name. We don't have the ability to see this
02:46
drop down that we see here to remove or change roles. We can leave the team and we can leave the team in here as long as we have another team that we belong to. So we always have to have one team here that's why we don't see that leave team option here.
02:59
So we can go ahead and leave the team. We can see a list of team members as this other user but we can't really do much else. Okay so Mabel is a team member. Let's go ahead and change her role over to a team admin and that's just as easy as doing that. Now when we give this a refresh you can
03:15
see that Mabel is a team admin. They can invite people, do whatever they need to and of course we can also remove them from the team as well. So let's go ahead and remove them. They are gotten rid of and when we go ahead and refresh this we're back to Mabel. So everything's automatically
03:29
switched over to this user's personal team as well. So this looks pretty simple on the surface but behind the scenes there are lots of stuff that we're going to do with things like roles and permissions. So we'll create out a general seeder for our admin.
03:41
We'll assign them any number of permissions and you can use this seeder in production as well. So you can just add as many roles as you want and go ahead and just follow the pattern of the entire course of creating new features out to build in whether someone can do
03:55
something. Now basically once we're within a team anywhere that we are within our application will be in the context of the team that we're currently in. So if you wanted to say for example list out projects within this team on the dashboard you can just grab the
04:10
current team and grab all projects as part of that team. So once you've got the foundations down you can just start to build on this and build out what you need. We're also going to be testing everything that we build here with PEST. So if you're even new to testing or you're new to PEST
04:22
I'm going to show you how to create some really short concise tests for testing all of the functionality here. Of course we've got a lot of things to test around roles and permissions which is really important so we'll be covering all of that as
04:34
well. So like I said we're probably going to be adding to this course and you'll find some additional features at the end but this is the base of what we're building. Okay let's get started and master Teams, Roles and Permissions with Laravel.
38 episodes4 hrs 36 mins

Overview

Need team functionality in your Laravel application? Let’s build it from scratch.

We’ll cover the basics of creating teams, switching between them, sending secure team invites by email, and managing team members.

Powering everything will be roles and permissions for each member, with the ability to switch roles directly from your team dashboard.

Once you’re done, you’ll have mastered team functionality in Laravel.

Alex Garrett-Smith
Alex Garrett-Smith
Hey, I'm the founder of Codecourse!

Episode discussion

No comments, yet. Be the first!