Use value() helper in 'when' method#55465
Conversation
|
@mohammadrasoulasghari the difference is that one can use the In that case, any project requiring the |
|
List of packages that are dependent on https://packagist.org/packages/illuminate/conditionable/dependents?order_by=downloads |
|
@rodrigopedra Thank you for carefully reviewing the changes and accuracy. As shown in the link you provided, illuminate/collections is already listed as a dependency, correct? And the value() helper is defined within that package at this path: So just to clarify — if illuminate/collections is indeed a required dependency of the package, and value() is part of that package, where exactly is the issue? |
|
@mohammadrasoulasghari, it is actually the opposite. The link lists the packages which are dependent upon You can check framework/src/Illuminate/Conditionable/composer.json Lines 16 to 18 in 3faeb07 |
|
Also, the link shows only published packages which depend on There also can be other projects, not published as packages, which depend on |
Ah yes, you're right — I was wrong about this. |

When using the when method, it first checked if the given value was a Closure and then executed it.
This is essentially the same logic as value() helper, which was being re-implemented here.
framework/src/Illuminate/Collections/helpers.php
Lines 234 to 237 in 17786ca
This PR replaces that duplicated logic with a direct call to value().
similar in #54650