Commit e2bc57c3 authored by Jens Segers's avatar Jens Segers

Merge #383

parent e0a3cda2
...@@ -4,6 +4,7 @@ use DateTime; ...@@ -4,6 +4,7 @@ use DateTime;
use MongoId; use MongoId;
use MongoDate; use MongoDate;
use Carbon\Carbon; use Carbon\Carbon;
use ReflectionMethod;
use Illuminate\Database\Eloquent\Relations\Relation; use Illuminate\Database\Eloquent\Relations\Relation;
use Jenssegers\Mongodb\Eloquent\Builder; use Jenssegers\Mongodb\Eloquent\Builder;
use Jenssegers\Mongodb\Relations\EmbedsOneOrMany; use Jenssegers\Mongodb\Relations\EmbedsOneOrMany;
...@@ -232,6 +233,11 @@ abstract class Model extends \Jenssegers\Eloquent\Model { ...@@ -232,6 +233,11 @@ abstract class Model extends \Jenssegers\Eloquent\Model {
// embedded model. If so, we need to return the result before it // embedded model. If so, we need to return the result before it
// is handled by the parent method. // is handled by the parent method.
if (method_exists($this, $camelKey)) if (method_exists($this, $camelKey))
{
$method = new ReflectionMethod(get_called_class(), $camelKey);
// Ensure the method is not static to avoid conflicting with Eloquent methods.
if ( ! $method->isStatic())
{ {
$relations = $this->$camelKey(); $relations = $this->$camelKey();
...@@ -251,6 +257,7 @@ abstract class Model extends \Jenssegers\Eloquent\Model { ...@@ -251,6 +257,7 @@ abstract class Model extends \Jenssegers\Eloquent\Model {
return $this->getRelationshipFromMethod($key, $camelKey); return $this->getRelationshipFromMethod($key, $camelKey);
} }
} }
}
return parent::getAttribute($key); return parent::getAttribute($key);
} }
......
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