|
|
@@ -131,6 +131,23 @@ class EducationModel extends Model
|
|
|
// }
|
|
|
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据 ID 获取记录
|
|
|
+ *
|
|
|
+ * @param int $id 记录 ID
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ public function get($id)
|
|
|
+ {
|
|
|
+ $result = $this->where(['id' => $id])->find();
|
|
|
+ if ($result) {
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 修改分类
|
|
|
*
|
|
|
@@ -145,7 +162,13 @@ class EducationModel extends Model
|
|
|
'sort' => $sort,
|
|
|
'name' => $name,
|
|
|
];
|
|
|
- if ($this->allowField(['sort', 'name'])->save($data, ['id' => $id])) {
|
|
|
+ $cate = $this->get($id);
|
|
|
+ if (!$cate) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ $cate->allowField(['sort', 'name']);
|
|
|
+ $result = $cate->save($data);
|
|
|
+ if ($result !== false) {
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|