Commit e2bc57c3 authored by Jens Segers's avatar Jens Segers

Merge #383

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