Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: illuminate/collections
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v11.23.4
Choose a base ref
...
head repository: illuminate/collections
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v11.23.5
Choose a head ref
  • 1 commit
  • 1 file changed
  • 2 contributors

Commits on Sep 12, 2024

  1. [11.x] add lazy default to when helper (#52747)

    * add lazy default to when helper
    
    * Update helpers.php
    
    ---------
    
    Co-authored-by: Taylor Otwell <taylor@laravel.com>
    rodrigopedra and taylorotwell authored Sep 12, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    cbea9d7 View commit details
Showing with 6 additions and 5 deletions.
  1. +6 −5 helpers.php
11 changes: 6 additions & 5 deletions helpers.php
Original file line number Diff line number Diff line change
@@ -239,18 +239,19 @@ function value($value, ...$args)

if (! function_exists('when')) {
/**
* Output a value if the given condition is true.
* Return a value if the given condition is true.
*
* @param mixed $condition
* @param \Closure|mixed $output
* @param \Closure|mixed $value
* @param \Closure|mixed $default
* @return mixed
*/
function when($condition, $output)
function when($condition, $value, $default = null)
{
if ($condition) {
return value($output);
return value($value, $condition);
}

return null;
return value($default, $condition);
}
}