Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
laravel-mongodb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sinan
laravel-mongodb
Commits
e0f39d5f
Commit
e0f39d5f
authored
Oct 15, 2015
by
alexandre-butynski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Overwrite Laravel base query builder exists method
Fix #607
parent
b6139331
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
0 deletions
+16
-0
Builder.php
src/Jenssegers/Mongodb/Query/Builder.php
+10
-0
QueryTest.php
tests/QueryTest.php
+6
-0
No files found.
src/Jenssegers/Mongodb/Query/Builder.php
View file @
e0f39d5f
...
...
@@ -349,6 +349,16 @@ class Builder extends BaseBuilder {
}
}
/**
* Determine if any rows exist for the current query.
*
* @return bool
*/
public
function
exists
()
{
return
!
is_null
(
$this
->
first
());
}
/**
* Force the query to only return distinct results.
*
...
...
tests/QueryTest.php
View file @
e0f39d5f
...
...
@@ -206,6 +206,12 @@ class QueryTest extends TestCase {
$this
->
assertEquals
(
6
,
$count
);
}
public
function
testExists
()
{
$this
->
assertFalse
(
User
::
where
(
'age'
,
'>'
,
37
)
->
exists
());
$this
->
assertTrue
(
User
::
where
(
'age'
,
'<'
,
37
)
->
exists
());
}
public
function
testSubquery
()
{
$users
=
User
::
where
(
'title'
,
'admin'
)
->
orWhere
(
function
(
$query
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment