Permalink
Browse files

slightly improved BaseModel::resolve()

  • Loading branch information...
1 parent 23fd2b1 commit 22641f44496586d0df917e1e577d1bcf25d9ba6c @d1rk d1rk committed Mar 11, 2013
Showing with 3 additions and 4 deletions.
  1. +3 −4 models/BaseModel.php
View
@@ -304,7 +304,7 @@ public function resolve($entity, $fields = null) {
break;
}
- $return = true;
+ $return = null;
foreach ($fields as $field) {
if (preg_match('/^(.+)_id$/', $field, $matches)) {
list($attribute, $name) = $matches;
@@ -318,10 +318,9 @@ public function resolve($entity, $fields = null) {
continue;
}
$res = $model::first($id);
- if (!$res) {
- continue;
+ if ($res) {
+ $return = $entity->$name = $res;
}
- $return = $entity->$name = $res;
}
}
return (count($fields) > 1) ? $entity : $return;

0 comments on commit 22641f4

Please sign in to comment.