-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[6.x] Add existsOr and doesntExistOr to the querybuilder #30495
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2406,6 +2406,28 @@ public function doesntExist() | |
return ! $this->exists(); | ||
} | ||
|
||
/** | ||
* Execute the given callback if no rows exist for the current query. | ||
* | ||
* @param \Closure $callback | ||
* @return mixed | ||
*/ | ||
public function existsOr(Closure $callback) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Allow all types here (should only be closure and bool, but there is some time till union types will be available). |
||
{ | ||
return $this->exists() ? true : $callback(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And return I prefer |
||
} | ||
|
||
/** | ||
* Execute the given callback if rows exist for the current query. | ||
* | ||
* @param \Closure $callback | ||
* @return mixed | ||
*/ | ||
public function doesntExistOr(Closure $callback) | ||
{ | ||
return $this->doesntExist() ? true : $callback(); | ||
} | ||
|
||
/** | ||
* Retrieve the "count" result of the query. | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to typehint Closure|bool