Skip to content
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

Merged
merged 3 commits into from
Sep 10, 2021
Merged

[8.x] Adds policy option to make:model #38725

merged 3 commits into from
Sep 10, 2021

Conversation

tfevens
Copy link
Contributor

@tfevens tfevens commented Sep 8, 2021

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.

This is purely for convenience and has no far-reaching impacts for users.

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.
@derekmd
Copy link
Contributor

derekmd commented Sep 8, 2021

This change has been declined 3 times before (#25787 #28393 #28845), I assume because policies are considered an optional feature. Subdirectory app/Policies/ and PHP namespace App\Policies don't exist by default in Laravel apps until the command make:policy is called the first time.

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",
Copy link
Contributor

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

Copy link
Contributor Author

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!

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@GrahamCampbell GrahamCampbell changed the title Adds policy option to make:model [8.x] Adds policy option to make:model Sep 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants