Skip to content

[9.x] Conditionable should return HigherOrderWhenProxy only when the args number is exactly 1 - #42555

Merged
taylorotwell merged 1 commit into
laravel:9.xfrom
leo108:9.x
May 31, 2022
Merged

[9.x] Conditionable should return HigherOrderWhenProxy only when the args number is exactly 1#42555
taylorotwell merged 1 commit into
laravel:9.xfrom
leo108:9.x

Conversation

@leo108

@leo108 leo108 commented May 29, 2022

Copy link
Copy Markdown
Contributor
$extraFilter = $condition ? null : function ($query) { $query->where('field', 'value'); };
$query = User::query()->when($extraFilter !== null, $extraFilter);

// When $condition is false, which means $extraFilter is null
// Before: Illuminate\Support\HigherOrderWhenProxy
// After: Illuminate\Database\Eloquent\Builder
dump(get_class($query));

@BrandonSurowiec

Copy link
Copy Markdown
Contributor

A simple test should be added.

@leo108
leo108 force-pushed the 9.x branch 2 times, most recently from 3f58965 to dddfa50 Compare May 29, 2022 13:32
@leo108

leo108 commented May 29, 2022

Copy link
Copy Markdown
Contributor Author

@BrandonSurowiec Done

@taylorotwell
taylorotwell merged commit 3277687 into laravel:9.x May 31, 2022
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.

3 participants