Laravel Permissions Example: Implementing RBAC with GLM 5.1 Coding Assistant
Chapters6
Introduction to using GLM 5.1 with Olama in a Laravel project, noting cloud availability and the model context limit.
Tony Xhepa tests GLM 5.1 with Laravel 13 to implement RBAC using Spatie-like permissions, showcasing cloud model usage and open code workflow.
Summary
Tony Xhepa walks through a practical Laravel RBAC setup using the GLM 5.1 model. He explains choosing Olama as the model source and demonstrates the cloud version of GLM 5.1 to generate a fully configured Laravel project with the Spatie-like permissions package. The video covers creating a fresh Laravel 13 project, installing dependencies, publishing migrations, and configuring the User model and guards. Tony shows the resulting admin routes, middleware, and dashboard views, then tests a login flow with a sample test user. He notes limitations of the free cloud tier, including prompt limits and reset timelines, and finally tweaks an authorization call in App/SCP/Controller to switch to a gate/facade pattern. The overall takeaway is that GLM 5.1 can bootstrap a working RBAC implementation in Laravel 13, but cloud usage has caps that affect long runs.
Key Takeaways
- GLM 5.1 cloud is used to generate a Laravel 13 project configured with the Spatie-like permissions package (install, publish migrations, configure user model, and guards).
- The sample app defines an admin area protected by an admin middleware, with routes such as /admin/dashboard and /admin/users and corresponding admin controller logic.
- A test user is created and used to verify access control; initially the route /admin/dashboard is restricted until the user is granted the right roles and permissions.
- A code adjustment is demonstrated: replacing a hard authorize call with a gate/facade approach in App/SCP/Controller to enable permission checks (authorize to gate/eliminate facade gate).
- The video highlights cloud-only access for GLM 5.1 during the recording, noting free-tier prompt limits and a two-hour reset cycle when using the cloud model.
- The workflow includes using VS Code with open code via Ollama, launching GLM 5.1 cloud, and running PHP artisan migrate:fresh --seed to seed test data for RBAC testing.
Who Is This For?
Laravel developers curious about RBAC and AI-assisted bootstrapping, especially those who want to see how GLM 5.1 can scaffold a permissions-based admin area in Laravel 13 using a cloud model.
Notable Quotes
"Hello friends, Tony here. Welcome."
—Intro by the presenter establishing the video and persona.
"Now things to keep in mind is uh this model has the context maximum of 198 almost uh 200k so not a big deal but yeah here we can see the coding performance so GPT 4.5 uh cloud opus and then comes this GLA"
—Tony discusses model context and performance notes for GLM 5.1 vs other models.
"You are an expert Laravel developer. Your task is to install and fully configure the spotty Laravel permission package in an existing Laravel application."
—The prompt used for the GLM to generate the Laravel permissions setup.
"So I should activate the LA best practices and brainstorming skill level best practices because we use open code for that is going to activate the skills."
—He mentions enabling best-practices settings in the OpenCode workflow.
"Yeah, you have admin access. You can manage users and we have here a link to go to you can edit post and you can view content."
—Description of the permission-guarded admin interface after logging in.
Questions This Video Answers
- How can I implement RBAC in Laravel 13 with a ready-made permissions package like Spatie's, as demonstrated in this video?
- What are the limitations of using GLM 5.1 cloud for Laravel project scaffolding, and how does it affect longer runs?
- How do you switch authorization from a direct authorize call to a gate or facade approach in Laravel based on Tony Xhepa's example?
- What steps are involved in bootstrapping a Laravel project with a cloud AI model, including migrations, guards, and admin routes?
Laravel 13Laravel PermissionsRBACGLM 5.1Olama/OpenCodeCloud modelSpatie-like permissionsAdmin routesMiddlewareGate vs authorize
Full Transcript
Hello friends, Tony here. Welcome. In today's video, I'm going to work with another model. I'm going to use Olama for this and I'm going to work with this GLM 5.1 which is a new release and we're going to see if this is uh very good with Laravel. Now things to keep in mind is uh this model has the context maximum of 198 almost uh 200k so not a big deal but yeah here we can see the coding performance so GPT 4.5 uh cloud opus and then comes this GLA we're going to see for that I want to inst installed a Laravel fresh project where the see laravel 13 and then I'm going to use the open code also we can work with the cloud code we can say and yeah I had a comment on YouTube how I work with the open code and you can just download the model or you can use the cloud model if you want but as I told you the in the previous video with the cloud yeah if we work hard you can reach the limits.
But if you download the model just say launch open code dash model and choose the model you want. So for example, GLM 5.1 or if you work with the Gemma 4 and if you have download the Gemma in my case I have downloaded this 26 billion. Okay. So I can say hama launch opencoder-model and copy this Gemma and paste it right here. You need to have the open code installed. Okay. Now let's work with uh this new one which is the GLM 5.1 and right now is only the cloud version. So we don't have a model to download.
I think after one or two weeks is coming also the download version but for now let's use this cloud one. And first let's create the Laravel project. So let's say Laravel new and I'm going to say all lama here. Let's choose live wire. And in this video, what I'm going to do is I'm going to ask this GLM. I have prepared a prompt. And here is the prompt. You are an expert Laravel developer. Your task is to install and fully configure the spotty Laravel permission package in an existing Laravel application. Follow the steps. Install the package, publish and run migrations, configure the user model, and so on.
And this is uh this prompt is generated by the AI. Let's see. I'm going to run the mpm install also. Let's just show you the full prompt. So you can pause the video and see the prompt now which I'm going to choose cloud code and the open code only. Hit enter. And then we need to see data lama. Okay. Let's open with VS Code just to see what this is going to build. And next I'm going to launch the open code with the Olama. So Lama launch open code. And in this case we're going to work with this GLM 5.1 cloud.
So launch open code D-model. And we're going to work with this GLM. the for the first time it's going to say proity yes and a new release I'm going to say confirm okay so you can see now we have the model GLM 5.1 cloud and I'm going to copy the prompt and paste it and we're to see what this is going to do hit enter okay so I should activate the LA best practices and brainstorming skill level best practices because we use open code for that is going to activate the skills. Okay friends, so we are back.
Uh it's not finished yet because we have hit the limits as you can see only by this prompt if you use a free version on the cloud. Yeah, 100% used and it's going to reset after 2 hours. But let's see what this has. I think everything is completed except the pest test and the bind. Okay. So now I'm going to see what the model has been built. First it's got a models user model and yeah of course has added this has roles spotty permission traits roles. Good. Anything else? No. Now let's go to HTTP admin controller.
We have this dashboard returning the view admin dashboard and then users. This authorize manage users. If we go to resources views, we have admin dashboard and users. So I have created two views. Let's go to routes web and we have middleware ro admin. So it's protected by the ro admin and we have the router get admin dashboard admin controller class dashboard and also admin users users here also under the name. Good. Let's go and see the database migrations permissions you got. Let's see the cedars roles and permissions. Okay, if we see here what we have set is the install, publish and error migration, configure the user model, then configure the out guard.
Okay, see the roles. Uh yeah, let's go also bootstrap app and we have middleware alias for role permission roer permission. Okay, good. Next example uses show how to assign a role to user and then create a sample controller admin controller blade example and testing. Let's open now this project here. So I'm going to sayama test. Let's register create the account and we have the dashboard. What if I go to /admin/dashboard and we have user does not have the right roles. And here we say if we have a user because if the database we created the test user.
So let me just come here and run PHP artisan migrate fresh dash seed. Okay let's go refresh. I'm going to go to login use this test example. use the password and we are logged in. But now if I go to slash admin slash dashboard. Yeah, you have admin access. You can manage users and we have here a link to go to you can edit post and you can view content. We can go now to admin users but we have an error. So the authorize method here if we go to app SCP controller we have this authorize we can change that to gate eliminate support facad gate authorize let's save from here refresh and now user management you have permission to manage users okay I think uh has done a good job but for now is only on the cloud.
So you need to work either with uh Olama cloud or with the open router if you also in the open router this is going to cost you. But yeah, that's it all about this video. What I wanted to show you an example how you can use this model, the GLM 5.1 and how good is this at least with Laravel project. And if you like such a videos, don't forget to subscribe to my channel, like the video, share with your friends and I'm going to see you in another video. 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.








