Laravel Filament Admin Panel: [3] Permissions

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
**The content of this video is intended for educational and entertainment purposes.** **It is NOT production ready.** If you're new to the channel, welcome. If you're not new, welcome back. Today we're going to be continuing on with our Filament admin panel series and we are at the point where we have our roles and permissions. We have a whole configuration set up for that system. We just need a front end in order to be able to deal with it. If you're curious about the different things that we're going to be doing, I highly suggest you take a look at the preview episode, and you'll have a better idea of what to expect from this series. What I want to do today is to start working on our permissions, because it is the simplest place to start. Now the only thing that we'll really need to do with the permissions is to create a name for the permissions. That's how they'll get created, so I decided instead of having an entire page with a create, edit, and list feature, that we would just do a simple modal. If you go to the documentation, and you take a look right here in the getting started section of the admin panel resources, getting started. This is where we are. You take a look right up top, we'll have creating a resource and then simple modal resources. Let's go ahead and click that. Right here is the command that we will need to create this, so let's go ahead and add that. We'll open up our terminal, whichever terminal you're using it generally does not matter, this is what I'm using. We're going to do PHP artisan make Filament resource, and we'll call it permission, and we need to add the simple flag on that. It was successfully created. Let's go see where it is. We'll go to our app Filament permission resource. This is the folder, and as you can see there's only one field in here but if we go to permission resource, this is pretty much where we're going to be doing everything. If we take a look at this, you see that we have the model which is the permission model. We have a navigation icon which is the HeroIcon, and it's o for -- I can't remember what O is for, but collection. That's just basically the icon, and if you take a look here this is the form. This is where we'll be building out our very, very small and simple form, and then we have a table section down here which are different fields from the database. There's some actions, bulk actions. There's an index. This is the page that it's going to be on, so it'll just have a link to it, but this is what that link will point to. From here we can go ahead and refresh this, and now you can see we have this permission link right here. If we click it -- app models permission not found. Let's go and fix this. This permission that they are bringing in is actually from the app models folder, and Spatie has it within the vendor files. We're just going to go ahead get rid of that, and we'll import the new one, and it's going to be this right here, and as you can see it's been imported here. Now we can try it again. Okay, great. So these are the permissions that we have in there. Clearly, you can't see any of them because we haven't done anything with that yet, but at least you can see that now that's set up. The first thing that we want to do here is work on the table, and that is the page that we just saw. We're going to go ahead, I'm going to move that. Nothing to do with the actual functionality, it's just my pet peeve. Then we'll go to columns, and the columns we're going to have, the first one is going to be a text column, and we'll make sure that imports. We're going to do the short form down here, because it really is a lot nicer, and cleaner, and neater. We'll go ahead and do make ID, and this we're just going to want it to be sortable, and then we'll do this again and instead of ID this time it'll be name. Then not only will it be sortable, we'll also make it searchable so that we'll have a little search box to search for it, obviously. The next one that we're going to make, it is for created at, and let me move this down a line so it looks a little bit better. We're going to have sortable and searchable, but we're also going to have to make sure that this is a date, and actually it's not date it's date time, and then it's for the day the month and the year and these are PHP formats. Just look at the documentation for that. That's pretty much it. Let's go and see what this looks like now. Okay, look at that. A lot neater. We have our IDs here. We have the names of all of our permissions. We have the dates that were created and we just configured the styling for them. We also have an edit and delete button, and that came with the installation. Let's go ahead and try this. We can try to create a new one, and as you can see we have this modal. Let's go and work on this form. Let's head up and work on this form up here. For the schema, I want to bring in the card component, and here we're going to make, and then we need to add another schema, and then we're going to just need a text input, make name. Let's go ahead and see what we have. Okay, so that looks a lot nicer, and we can go ahead and create one, and that should be at the very end. Let's go ahead and look at the end, and there it is. Now obviously we need some validation on that because that makes no sense at all. But before we do, we also have the search functionality, and that was just by chaining on that function, that searchable function. Why don't we get all of the create, and we didn't even finish typing it out, but these are the permissions that we have that start with create. So right out of the box you can see that the searchable just works. Let's go ahead and deal with the validation on this. The first one that we want to do is, we want to make it unique and we don't have to add any other things in here. It's just going to know that it's going to be unique to the permissions table, and then required. Let's go ahead and try to see if this works. Should probably get rid of that. Okay, go ahead and refresh it again. We'll try to create a new one, and let's try to put -- we'll just copy one of these. The name has already been taken, and if we just get rid of that all together we already have the front end validation for that. We've already seen that it works, so now we can go ahead and close this, and let's say we wanted to go ahead and edit that. This is the one that we just made. We'll go ahead and edit it. We can leave it like that, it shouldn't matter but let's go ahead and try something else. Okay, and then it has been updated, and you can see we have a little saved notification up here, and then if we wanted to go ahead and delete it, are you sure? You can cancel or delete, and delete. It's fairly simple to set up and get going, but one of the things that I want to do first is, I want to go ahead and change this icon to something a little bit more appropriate. Okay, so instead of the collection we're going to just use key. Okay, there we go, and something else we can do is we can create a drop down so that we can section off different parts of this admin panel. To handle all of the admin sort of things that we're doing which is the roles, permissions, admins, users and giving them roles and permissions and stuff like that, we can make a different section for that. To do that we would come under here and we do protected static question mark string dollar navigation group, and that will equal. Why don't we just call it admin management. I think that's appropriate. If I could spell it correctly. Management and semicolon. Okay, let's see what we have from this. Very cool, and here's our drop down. So now we can hide it, we can show it, we can hide it, we can show it. Fantastic, and if you want to take a look at this manage permission file that came when we created this resource, all it has is just a resource permission resource. It's just allowing it to have some actions for that resource, and that's all that that is. If you're enjoying the content, please go ahead and click that like button as it really does help out the channel. Here's a video YouTube thinks you'll like, and here's a playlist to follow along. Thanks for watching. I'll see you next time.
Info
Channel: Designated Coder
Views: 6,729
Rating: undefined out of 5
Keywords: laravel, laravel 8, designated coder, #dezignatedcoder, designatedcoder, laravel admin panel, laravel 9, filament, filament admin panel, how to create an admin panel in laravel 8 from scratch, how to create an admin panel in laravel 9 from scratch, laravel admin panel from scratch, laravel user management system, laravel multi auth, laravel multiple authentication, spatie permission laravel 8, spatie permission laravel 9, laravel admin panel tutorial, #designatedcoder
Id: yIaB8kTaQPQ
Channel Id: undefined
Length: 8min 41sec (521 seconds)
Published: Thu Oct 06 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.