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

[11.x] Unless helper #52844

Closed
wants to merge 3 commits into from
Closed

Conversation

michaelnabil230
Copy link
Contributor

Add unless() Helper Function

This PR introduces a new unless() helper function to provide a more expressive alternative to conditional logic in Laravel. The unless() function complements the existing when() function by handling the inverse logic, allowing developers to execute a given callback or return a value if the condition evaluates to false.

Example Usage:

$result = unless(false, 'Hello'); // returns 'Hello'
$result = unless(true, 'Hello', 'World'); // returns 'World'

@taylorotwell
Copy link
Member

Thanks for your pull request to Laravel!

Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.

If applicable, please consider releasing your code as a package so that the community can still take advantage of your contributions!

@michaelnabil230 michaelnabil230 deleted the unless-helper branch September 19, 2024 11:15
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