Skip to content

Commit d0ba26b

Browse files
committed
init
1 parent b071443 commit d0ba26b

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

module/Blog/Admin/Controller/BlogController.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ protected function crud(AdminCRUDBuilder $builder)
4949
$filter->like('title', '标题');
5050
})
5151
->hookSaving(function (Form $form) use (&$updatedCategoryIds) {
52-
$blog = ModelUtil::get('blog', $form->itemId());
53-
if (!empty($blog['categoryId'])) {
54-
$updatedCategoryIds[] = $blog['categoryId'];
52+
if ($form->itemId()) {
53+
$blog = ModelUtil::get('blog', $form->itemId());
54+
if (!empty($blog['categoryId'])) {
55+
$updatedCategoryIds[] = $blog['categoryId'];
56+
}
5557
}
5658
return Response::generateSuccess();
5759
})

vendor/modstart/modstart/src/Core/Dao/ModelUtil.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ public static function first($model, $where, $fields = ['*'], $order = null)
204204
*/
205205
public static function get($model, $where, $fields = ['*'], $order = null)
206206
{
207+
if (null === $where) {
208+
return null;
209+
}
207210
if (is_string($where) || is_numeric($where)) {
208211
$where = ['id' => $where];
209212
}

0 commit comments

Comments
 (0)