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

Add query buider 'unless' method (inverse of 'when') #19738

Merged
merged 1 commit into from
Jun 23, 2017

Conversation

calebporzio
Copy link
Contributor

Here is a recent snippet of code where "unless" would have been useful:

without "unless"

$query->when($sortColumn !== 'title', function ($query) {
    return $query->orderBy($sortColumn, 'desc');
})

with "unless"

$query->unless($sortColumn === 'title', function ($query) {
    return $query->orderBy($sortColumn, 'desc');
})

I also would like this method in Collection.php - if people like the concept, I'll submit another PR, but let's see how this goes.

Thanks for all the hard work!

  • Caleb

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