Commit 89e059b5 authored by Jens Segers's avatar Jens Segers

Tweaking id accessor for #108

parent 01c4e0a6
...@@ -48,7 +48,7 @@ abstract class Model extends \Jenssegers\Eloquent\Model { ...@@ -48,7 +48,7 @@ abstract class Model extends \Jenssegers\Eloquent\Model {
// If there is an actual id attribute, then return that. // If there is an actual id attribute, then return that.
if ($value) return $value; if ($value) return $value;
return $this->getKey(); return $this->attributes[$this->getKeyName()];
} }
/** /**
......
...@@ -6,6 +6,7 @@ use MongoDate; ...@@ -6,6 +6,7 @@ use MongoDate;
use DateTime; use DateTime;
use Closure; use Closure;
use Illuminate\Database\Query\Expression;
use Jenssegers\Mongodb\Connection; use Jenssegers\Mongodb\Connection;
class Builder extends \Illuminate\Database\Query\Builder { class Builder extends \Illuminate\Database\Query\Builder {
...@@ -507,11 +508,19 @@ class Builder extends \Illuminate\Database\Query\Builder { ...@@ -507,11 +508,19 @@ class Builder extends \Illuminate\Database\Query\Builder {
*/ */
public function raw($expression = null) public function raw($expression = null)
{ {
// Execute the closure on the mongodb collection
if ($expression instanceof Closure) if ($expression instanceof Closure)
{ {
return call_user_func($expression, $this->collection); return call_user_func($expression, $this->collection);
} }
// Create an expression for the given value
else if (!is_null($expression))
{
return new Expression($expression);
}
// Quick access to the mongodb collection
return $this->collection; return $this->collection;
} }
......
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