Commit e0f39d5f authored by alexandre-butynski's avatar alexandre-butynski

Overwrite Laravel base query builder exists method

Fix #607
parent b6139331
......@@ -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.
*
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment