-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[8.x] Adds policy option to make:model #38725
Conversation
When creating a model using the `artisan make:model` command, there is no option to create a Policy at the same time. This change adds the `--policy` option to the `make:model` command, and includes it in the `--all` option as well.
Updated to pass CI style guides.
This change has been declined 3 times before (#25787 #28393 #28845), I assume because policies are considered an optional feature. Subdirectory php artisan make:model Foo && php artisan make:policy Foo |
$policy = Str::studly(class_basename($this->argument('name'))); | ||
|
||
$this->call('make:policy', [ | ||
'name' => "{$policy}Policy", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't you want to pass --model
here as well, that way the policy is generated for the model
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had debated that myself. Left it off as I felt that a quick scaffold would be better than nothing. But, if the community thinks that this is an option that would be better added in, it's something I can include quick and easy!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we were to ever include this it would definitely need to pass --model
to make:policy
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
When creating a model using the
artisan make:model
command, there is no option to create a Policy at the same time. This change adds the--policy
option to themake:model
command, and includes it in the--all
option as well.This is purely for convenience and has no far-reaching impacts for users.