mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
改进Route类setRule方法 修正BelongsToMany类的attach方法
This commit is contained in:
@@ -296,12 +296,14 @@ class Route
|
||||
} elseif ('$' == substr($rule, -1, 1)) {
|
||||
// 是否完整匹配
|
||||
$option['complete_match'] = true;
|
||||
$rule = substr($rule, 0, -1);
|
||||
}
|
||||
} elseif (empty($option['complete_match']) && '$' == substr($rule, -1, 1)) {
|
||||
// 是否完整匹配
|
||||
$option['complete_match'] = true;
|
||||
$rule = substr($rule, 0, -1);
|
||||
}
|
||||
|
||||
if (true == $option['complete_match'] && '$' == substr($rule, -1, 1)) {
|
||||
$rule = substr($rule, 0, -1);
|
||||
}
|
||||
|
||||
if ('/' != $rule || $group) {
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace think\model\relation;
|
||||
|
||||
use think\Db;
|
||||
use think\db\Query;
|
||||
use think\Exception;
|
||||
use think\Model;
|
||||
use think\model\Pivot;
|
||||
use think\model\Relation;
|
||||
@@ -269,7 +270,7 @@ class BelongsToMany extends Relation
|
||||
$pk = $this->parent->getPk();
|
||||
$pivot[$this->localKey] = $this->parent->$pk;
|
||||
$pivot[$this->foreignKey] = $id;
|
||||
return $this->query->table($this->middle)->insert($pivot);
|
||||
return $this->query->table($this->middle)->insert($pivot, true);
|
||||
} else {
|
||||
throw new Exception('miss relation data');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user