Skip to content

[5.4] Fix issue with case in authorizeResource#18435

Merged
taylorotwell merged 1 commit into
laravel:5.4from
devcircus:fix-authorize-resource-param-case
Mar 20, 2017
Merged

[5.4] Fix issue with case in authorizeResource#18435
taylorotwell merged 1 commit into
laravel:5.4from
devcircus:fix-authorize-resource-param-case

Conversation

@devcircus

Copy link
Copy Markdown
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