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

[5.4] Fix issue with case in authorizeResource #18435

Merged
merged 1 commit into from
Mar 20, 2017
Merged

[5.4] Fix issue with case in authorizeResource #18435

merged 1 commit into from
Mar 20, 2017

Conversation

devcircus
Copy link
Contributor

Should fix issue #18432
Will add some tests this evening.

Problem:

When using the "authorizeResource" method, by default, the method derives the parameter name from the passed model if it is not given as the secoond parameter. However, "strtolower" is used. If the model name contains multiple words, ie. "ProductionOrder", then the parameter becomes "productionorder", which will not work. We need "productionOrder".
So, currently, authorizeResource will always return false, unless the second parameter is provided as "productionOrder".

Solution:

Simply change the following line:

$parameter = $parameter ?: strtolower(class_basename($model));

to

$parameter = $parameter ?: lcfirst(class_basename($model));

@taylorotwell taylorotwell merged commit 3f693da into laravel:5.4 Mar 20, 2017
@devcircus devcircus changed the title fix issue with case in authorizeResource [5.4] Fix issue with case in authorizeResource Mar 21, 2017
@devcircus devcircus deleted the fix-authorize-resource-param-case branch March 21, 2017 15:51
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.

2 participants