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] Throws an error upon make:policy if no model class is configured #40348

Merged
merged 5 commits into from
Jan 13, 2022

Conversation

slavicd
Copy link
Contributor

@slavicd slavicd commented Jan 11, 2022

If the model config key is not present in auth.providers.users the make:policy command will silently spit out some very poor stub.

Fixes: #40345

@driesvints
Copy link
Member

@slavicd please provide a thorough explanation in the PR instead of linking to an issue so Taylor knows what this about. Thanks

@slavicd slavicd changed the title Fixes issue #40345 Throws an error upon make:policy if no model class is configured Jan 11, 2022
@taylorotwell
Copy link
Member

Thanks for your pull request to Laravel!

Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.

If possible, please consider releasing your code as a package so that the community can still take advantage of your contributions!

If you feel absolutely certain that this code corrects a bug in the framework, please "@" mention me in a follow-up comment with further explanation so that GitHub will send me a notification of your response.

@driesvints
Copy link
Member

@taylorotwell do you have another preference on how to solve this instead?

@slavicd
Copy link
Contributor Author

slavicd commented Jan 12, 2022

Is that an automated comment above, perhaps? @driesvints

@driesvints
Copy link
Member

@taylorotwell I need to re-open this or it won't show up in your inbox.

@driesvints driesvints reopened this Jan 13, 2022
@driesvints driesvints changed the title Throws an error upon make:policy if no model class is configured [8.x] Throws an error upon make:policy if no model class is configured Jan 13, 2022
@taylorotwell
Copy link
Member

I'm just going to make it return App\Models\User if it can't find one. The user can adjust it from there. Policies are fairly Eloquent based though.

@taylorotwell taylorotwell merged commit 472a05a into laravel:8.x Jan 13, 2022
@hmennen90
Copy link

:-D Just like my solution :-)

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.

Artisan command make:policy generates invalid policy code with a non-default user provider configuration
4 participants