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

[7.x] Add option to specify a custom guard for the policy #33210

Merged
merged 1 commit into from
Jun 15, 2020

Conversation

ghostal
Copy link
Contributor

@ghostal ghostal commented Jun 14, 2020

When using artisan make:policy, policies can only be generated with the user model found in the default guard's provider. This PR allows an optional --guard option to be specified to override this default behaviour with a non-default guard.

It also adds an --any-guard option, which overrides --guard, which will instead type hint Illuminate\Contracts\Auth\Access\Authorizable in the generated policy, allowing any guard to be used with the policy.

This PR should be fully backwards compatible as omitting both new options results in the existing behaviour (the default guard's provider model is used).

I wanted this because I have two guards, one for Administrators and one for Users.

@taylorotwell taylorotwell merged commit 0ee21ed into laravel:7.x Jun 15, 2020
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.

3 participants