SQLSTATE[HY000]: General error: 1366 Incorrect integer value: 'null' On Nullable column

SQLSTATE[HY000]: General error: 1366 Incorrect integer value: 'null' On Nullable column

当我尝试通过 laravel.

将一些可为 null 的整数值更新为 null 时,我的应用程序出现了一个奇怪的错误
SQLSTATE[HY000]: General error: 1366 Incorrect integer value: 'null' for column 'next' at row 1 (SQL: update `questions` set `content` = <strong>Kulitmu sering terlihat/terasa:</strong>, `next` = null, `order` = 9, `questions`.`updated_at` = 2021-02-14 17:18:29 where `id` = 9 and `questions`.`deleted_at` is null)

我尝试直接在 SQL 控制台上对错误执行 SQL,没有问题,更新正在接受可为 null 的整数列的 null 值,所以我认为它与 laravel 有关,但我找不到问题,任何帮助将不胜感激。

这是我用来执行更新的代码

    public function update(Request $request, $id)
    {
        $data = $this->validateRequest($request);

        $question = Question::where('id', $id)->first();
        $question->update($data);

        return response()->json([
            'question' => $question,
            'status' => 'Question has been updated'
        ]);
    }

    public function validateRequest($request)
    {
        $validator = Validator::make($request->all(), [
            'content' => 'required',
            'next' => 'nullable',
            'order' => 'required',
        ]);

        if ($validator->fails()) {
            throw(new ApiInvalidRequestData($validator->errors()));
        }

        return $validator->validated();
    }

万一以后有人遇到和我一样的问题,就我而言,问题是用Axios发布的FormData对象将每个值转换为字符串,包括空值,所以空值变成“null”,并将其保存到数据库时出错。问题不是 laravel 但在前端的 javascript 上,laravel 仍然很奇怪,因为它说生成的查询是 ... next = null ... 而不是 ... next = "null" ...