Commit 34cfb356 by Qiang Xue

Fixes #2713: using relations defined in behavior may throw exception in lazy loading.

parent 21f2f38b
...@@ -142,7 +142,7 @@ trait ActiveRelationTrait ...@@ -142,7 +142,7 @@ trait ActiveRelationTrait
*/ */
public function findFor($name, $model) public function findFor($name, $model)
{ {
if ($model->hasMethod('get' . $name)) { if (method_exists($model, 'get' . $name)) {
$method = new \ReflectionMethod($model, 'get' . $name); $method = new \ReflectionMethod($model, 'get' . $name);
$realName = lcfirst(substr($method->getName(), 3)); $realName = lcfirst(substr($method->getName(), 3));
if ($realName !== $name) { if ($realName !== $name) {
......
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