优化Route类的模型绑定

This commit is contained in:
thinkphp
2016-09-10 10:17:11 +08:00
parent 7a4df4c5f3
commit b1742361d0

View File

@@ -1348,7 +1348,6 @@ class Route
$model = $val; $model = $val;
$exception = true; $exception = true;
} }
$model = strpos($model, '\\') ? $model : Loader::model($model);
$where = []; $where = [];
$match = true; $match = true;
foreach ($fields as $field) { foreach ($fields as $field) {
@@ -1360,7 +1359,8 @@ class Route
} }
} }
if ($match) { if ($match) {
$result = $model::where($where)->failException($exception)->find(); $query = strpos($model, '\\') ? $model::where($where) : Loader::model($model)->where($where);
$result = $query->failException($exception)->find();
} }
} }
if (!empty($result)) { if (!empty($result)) {