Skip to content

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