Skip to content

Commit b5ff567

Browse files
committed
fix(control): 字段为 null 的处理
1 parent 2625496 commit b5ff567

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

laravel/app/Http/Controllers/Api/ArticleController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ public function update(Update $request, $id)
119119
// 老版本更新操作如下,新版本先查询再更新
120120
// Article::where('id', $id)->update($input)
121121
$article = Article::findOrFail($id);
122+
is_null($input['description']) && $input['description'] = '';
123+
is_null($input['cover_img']) && $input['cover_img'] = '';
122124
if ($article->update($input)) {
123125
return $this->out(200, ['data' => ['id' => $id]]);
124126
} else {

laravel/app/Http/Controllers/Api/CategoryController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public function store(Store $request)
6868
// 会出现 Unknown column 'guid' in 'field list' 不存在的字段入库报错问题
6969
// $rs = Category::insert($request->all());
7070
$input = $request->all();
71+
is_null($input['sort']) && $input['sort'] = 100;
7172
$model = new Category($input);
7273
if ($model->save()) {
7374
return $this->out(200, ['data' => ['id' => $model->id]]);

0 commit comments

Comments
 (0)