Commit 727f0e9e authored by Jens Segers's avatar Jens Segers

Merge pull request #80 from neoxia/master

orderBy() should accept uppercase order direction
parents 9829d49e e3f64f45
......@@ -268,7 +268,7 @@ class Builder extends \Illuminate\Database\Query\Builder {
*/
public function orderBy($column, $direction = 'asc')
{
$this->orders[$column] = ($direction == 'asc' ? 1 : -1);
$this->orders[$column] = (strtolower($direction) == 'asc' ? 1 : -1);
return $this;
}
......
......@@ -142,6 +142,9 @@ class QueryTest extends PHPUnit_Framework_TestCase {
$user = User::whereNotNull('age')->orderBy('age', 'asc')->first();
$this->assertEquals(13, $user->age);
$user = User::whereNotNull('age')->orderBy('age', 'ASC')->first();
$this->assertEquals(13, $user->age);
$user = User::whereNotNull('age')->orderBy('age', 'desc')->first();
$this->assertEquals(37, $user->age);
}
......
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