-
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
[5.4] Use the correct user model namespace in make:policy Command #19965
Conversation
* Replace the user model for the given stub. | ||
* | ||
* @param string $stub | ||
* @return string mixed |
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.
@return string mixed
isn't valid, should be just @return string
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.
Thanks, didn't notice that
Hard-coding |
@taylorotwell Right, working on a fix |
*/ | ||
protected function replaceUserModelNamespace($stub) | ||
{ | ||
return str_replace($this->rootNamespace().'User', config('auth.providers.users.model'), $stub); |
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.
A slight improvement
if ($this->rootNamespace().'User' !== config('auth.providers.users.model')) {
return str_replace($this->rootNamespace().'User', config('auth.providers.users.model'), $stub);
}
return $stub;
I've been creating new policies this days in a project where my models are under app/Models directory.
Every policy I created I needed to modify the namespace of the user's model.
I remembered that this information is available through the auth configuration file and ended up with this.
I want to thank @JosephSilber who taught me a lot on this Gates & Policies stuff.