Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Russelmhardy's avatar

permissions and roles laravel

hi all can I generate my permissions and roles for my projects without writing them from some services or application?

0 likes
7 replies
Russelmhardy's avatar

@drewdan i have a big crud in my projects so i ask about if can generate permission for each crud in my project without code theme from scratch

drewdan's avatar

@Russelmhardy How are you applying permissions to your controllers?

You can scaffold policies using php artisan make:policy which accepts a model as an argument to generate crud policies. I think polices are the best way to authorize cruddy controllers.

tykus's avatar

without writing them from some services or application

Struggling to understand what you mean by this part...

2 likes
drewdan's avatar

@tykus I think, they mean without having to write a package to do it? That's how I (perhaps wrongly) interpreted it

1 like
Russelmhardy's avatar

@tykus i have a big crud in my projects so i ask about if can generate permission for each crud in my project without code theme from scratch

tykus's avatar

@Russelmhardy roles and permissions are determined by your business rules, so there is no avoiding that aspect of your task. You will need to define the roles and the permissions; and you will have to ensure that the data that is visible, and actions available to your users, are enforced by checking the permission(s) at every one of your applications views/endpoints.

Otherwise, the underlying implementation can be outsourced to a third party package such as the aforementioned Laravel Permission, or Bouncer, or LaraTrust

Please or to participate in this conversation.