改进Route

This commit is contained in:
thinkphp
2016-09-09 20:40:39 +08:00
parent 766c410fe4
commit e63a162bc7

View File

@@ -1341,9 +1341,11 @@ class Route
if (is_array($val)) { if (is_array($val)) {
$fields = explode('&', $val[1]); $fields = explode('&', $val[1]);
$model = $val[0]; $model = $val[0];
$exception = isset($val[2]) ? $val[2] : true;
} else { } else {
$fields = ['id']; $fields = ['id'];
$model = $val; $model = $val;
$exception = true;
} }
$where = []; $where = [];
$match = true; $match = true;
@@ -1356,7 +1358,7 @@ class Route
} }
} }
if ($match) { if ($match) {
$result = $model::where($where)->findOrFail(); $result = $model::where($where)->failException($exception)->find();
} }
} }
if (!empty($result)) { if (!empty($result)) {