I was struggling with how to handle roles and permissions in my CRM project, but I came across your RUclips tutorial, and it was exactly what I needed. Thanks for sharing your knowledge-it's going to be a huge help!
Soooo timely!!!! This is one of my major concerns in the new project I'm working on cause i last watched a similar tutorial on this far back as 2019.... But I forgot how to implement it.
Thanks a lot! I started a project a few months ago, and I'm on the right track, but I need to fix the global scope on my models. All thanks to your help
The RILT stack is just the best of both worlds! And inertia 2 has no breaking changes 🫠 almost too good to be true. Thanks for your always hi-q videos 🙌
Hello! Thanks for all the effort you put into these videos, I really appreciate it. I wanted to ask if you could show how to create a more complex, scalable project in Laravel, beyond the usual CRUD apps. For example, it would be great to see something that includes SSO with Keycloak or Laravel Socialite and Passport for authentication. Also, using services or actions instead of controllers would be amazing. What I’m hoping for is a project that combines all the best practices you know into one high-level project.
I don't imagine "all the best practices" in one project, as every project is individual. Using services/actions instead of controllers are shown MULTIPLE times on my channel, just search for services/actions. With SSO/Keycloak/Passport, it's a separate BIG topic in itself, with also multiple ways/tools to implement it. But actually needed for a very small part of developers. So, for now, I'm postponing such videos. But will try to come up with something more complex.
Hey, love your videos man! I would love if you can make a video about FrankenPhp, how to actually write a caddyfile with frankenphp and create your app for production. I have setup my Laravel development with Sail but cannot figure out how to use Frankenphp and apply all the migrations, run workers and so on and go to production.
@@LaravelDaily If team_id is nullable in the roles table, how should the team_id in the model_has_roles table handle null values? Is the nullable() missing on it? I mean, should a user still have roles even if they are not part of any teams? If that's not the case, then what's the purpose of having team_id as nullable in the roles table?
Hello Sir, can you please tell me one simple thing, is livewire a truly SPA style? can it be as fast as Inertia/vuejs? I will love to hear your opinion.
Define "truly". It's "SPA style" - yes. But it works differently by sending requests to the SERVER which, in some people's opinions, disqualifies it from SPA, by definition. But it actually depends on what is your project, its goals, and components on the page.
Will this work in multi-database tenancy? Where do I place the roles and permissions tables in multi-database scenario, is it within the landlord or tenant database?
Wouldn't checking the team be cleaner if it was done in middleware that would be applied to all related routes? With global scope I expect you would need to define it for every single model. If you manage a clinic and you have models like patients, health records, prescriptions and such, that would make quite a lot of repetition. Or am I missing something?
Good point. Both can work, in my opinion, global scope in each Model feels pretty clear to me, not sure how the same/similar code in Middlewares would look less repetitive. I guess a head-to-head comparison would be an interesting topic for a future video.
@@LaravelDaily I am not used to scopes yet, but , I only assume here, a simple check you added to the gate might be enough in the middleware. I expect with multiple models you could provide a trait like BelongsToTeam... Hmm, as I am thinking about it right now, I am getting what you mean. Might need an extra step in model inheritance to be able to check it for all models in a single method...
Yeah, that's an interesting point of "I am not used to scopes yet": it's a good example of developers using what they are more comfortable with. Which is perfectly fine! Laravel allows multiple ways to implement the same thing, in many places.
Great video! Is it ok to name enums without the word "enum" in it? I mean, when I write controllers I name them like "ExampleController" or when I write actions their name would be "ExampleAction". So "Permission" should be "PermissionEnum" and "Role" should be "RoleEnum". No?
It's a personal preference, but yes, now I regret NOT using that suffix here. In this project specifically, I even had a problem of app/Enums/Role conflicting with Role Model from Spatie package, so I needed to make alias like "use App\Enums\Role as RoleEnum".
It is totally OK, we use enums in multiple projects without naming them as SomethingSomethingEnum. Symfony and Laravel do some magic in the background with some classes like FormRequest, Action, Controller and such, that's why it is better to suffix the classes. It is not a requirement but the suffixes are helpful in navigating the code.
@@martinsinansky2817 I don't think this is correct. Controllers extend "app/Http/Controllers/Controller", that has traits and extends "BaseController", so this is the "magic" you a talking about. There is no "magic" related to names. So you could name your controller as you want, but we all agree that it's wrong. About enums, you can name them without suffix but, as Mr. Povilas said, you could have issues with other classes that could have similar names (my first thought would be Models names). So you can, but I don't think you should, IMHO. ;)
I was struggling with how to handle roles and permissions in my CRM project, but I came across your RUclips tutorial, and it was exactly what I needed. Thanks for sharing your knowledge-it's going to be a huge help!
it seems i also followed the best practices, such videos makes me confident.
Soooo timely!!!! This is one of my major concerns in the new project I'm working on cause i last watched a similar tutorial on this far back as 2019.... But I forgot how to implement it.
Thanks a lot! I started a project a few months ago, and I'm on the right track, but I need to fix the global scope on my models. All thanks to your help
The RILT stack is just the best of both worlds! And inertia 2 has no breaking changes 🫠 almost too good to be true. Thanks for your always hi-q videos 🙌
Great summary Povilas! I like this sort of approach. I have done very similar myself before for a charity web app
the video is very helpful thanks Master
Hello! Thanks for all the effort you put into these videos, I really appreciate it. I wanted to ask if you could show how to create a more complex, scalable project in Laravel, beyond the usual CRUD apps. For example, it would be great to see something that includes SSO with Keycloak or Laravel Socialite and Passport for authentication. Also, using services or actions instead of controllers would be amazing. What I’m hoping for is a project that combines all the best practices you know into one high-level project.
I don't imagine "all the best practices" in one project, as every project is individual.
Using services/actions instead of controllers are shown MULTIPLE times on my channel, just search for services/actions.
With SSO/Keycloak/Passport, it's a separate BIG topic in itself, with also multiple ways/tools to implement it. But actually needed for a very small part of developers. So, for now, I'm postponing such videos. But will try to come up with something more complex.
@@LaravelDailythanks for all you do sir, much love from Nigeria
Hey, love your videos man!
I would love if you can make a video about FrankenPhp, how to actually write a caddyfile with frankenphp and create your app for production.
I have setup my Laravel development with Sail but cannot figure out how to use Frankenphp and apply all the migrations, run workers and so on and go to production.
I haven't used Frankenphp myself, so can't make a video about it, sorry.
Where can I find this project? I need to check out the models and migrations.
The repository is in the premium course: laraveldaily.com/course/roles-permissions
@@LaravelDaily If team_id is nullable in the roles table, how should the team_id in the model_has_roles table handle null values? Is the nullable() missing on it? I mean, should a user still have roles even if they are not part of any teams? If that's not the case, then what's the purpose of having team_id as nullable in the roles table?
Hello Sir, can you please tell me one simple thing, is livewire a truly SPA style? can it be as fast as Inertia/vuejs? I will love to hear your opinion.
Define "truly". It's "SPA style" - yes.
But it works differently by sending requests to the SERVER which, in some people's opinions, disqualifies it from SPA, by definition. But it actually depends on what is your project, its goals, and components on the page.
@@LaravelDaily THANK YOU
Hello!
Will you continue with this projet?? (Complex multi clinic)
I don't have any more plans here, I just wanted to show roles/permissions/teams. What other features you're suggesting that would be useful to others?
@@LaravelDaily I imagined you would finish the clinic system.
Will this work in multi-database tenancy?
Where do I place the roles and permissions tables in multi-database scenario, is it within the landlord or tenant database?
No, that's for single database. Can't answer about multiple databases, need to create a separate project and try it out
Graet!
Wouldn't checking the team be cleaner if it was done in middleware that would be applied to all related routes? With global scope I expect you would need to define it for every single model. If you manage a clinic and you have models like patients, health records, prescriptions and such, that would make quite a lot of repetition. Or am I missing something?
Good point. Both can work, in my opinion, global scope in each Model feels pretty clear to me, not sure how the same/similar code in Middlewares would look less repetitive. I guess a head-to-head comparison would be an interesting topic for a future video.
@@LaravelDaily I am not used to scopes yet, but , I only assume here, a simple check you added to the gate might be enough in the middleware. I expect with multiple models you could provide a trait like BelongsToTeam... Hmm, as I am thinking about it right now, I am getting what you mean. Might need an extra step in model inheritance to be able to check it for all models in a single method...
Yeah, that's an interesting point of "I am not used to scopes yet": it's a good example of developers using what they are more comfortable with. Which is perfectly fine! Laravel allows multiple ways to implement the same thing, in many places.
if you had multiple models you would create a trait or a global observer and would use on every model
Great video! Is it ok to name enums without the word "enum" in it? I mean, when I write controllers I name them like "ExampleController" or when I write actions their name would be "ExampleAction". So "Permission" should be "PermissionEnum" and "Role" should be "RoleEnum". No?
It's a personal preference, but yes, now I regret NOT using that suffix here. In this project specifically, I even had a problem of app/Enums/Role conflicting with Role Model from Spatie package, so I needed to make alias like "use App\Enums\Role as RoleEnum".
It is totally OK, we use enums in multiple projects without naming them as SomethingSomethingEnum. Symfony and Laravel do some magic in the background with some classes like FormRequest, Action, Controller and such, that's why it is better to suffix the classes. It is not a requirement but the suffixes are helpful in navigating the code.
@@martinsinansky2817 I don't think this is correct. Controllers extend "app/Http/Controllers/Controller", that has traits and extends "BaseController", so this is the "magic" you a talking about. There is no "magic" related to names. So you could name your controller as you want, but we all agree that it's wrong.
About enums, you can name them without suffix but, as Mr. Povilas said, you could have issues with other classes that could have similar names (my first thought would be Models names).
So you can, but I don't think you should, IMHO. ;)
@@LaravelDaily Thanks! 👍
I think that in truclips.net/video/Fe0VSwpZpaU/видео.html you may use 'match' that is more convinient than 'switch'
Yes, good point, it's a personal preference.