一个请求在数据库中应用许多更改

one request to apply many changes in the DB

我有很多记录需要在一个请求中编辑,所以我去了 POST 请求 尝试像这样编辑我的控制器中的数据:

foreach ($attr as $key){
        foreach ($key->item as $attribute) {
            if ($attribute['action'] == 'store') {
                $insert_array = [
                    'subject_quiz_id' => $key->subject_quiz_id,
                    'registration_record_id' => $attribute->registration_record_id,
                    'mark' => $attribute->mark
                ];

            }
        } }

这是我的邮递员:

{
"subject_quiz_id": "7",
"item": [{
        "action": "store",
        "registration_record_id": "7",
        "mark": "3"
    },
    {
        "action": "store",
        "registration_record_id": "7",
        "mark": "3"
    }]}

但它只是继续推送此错误:

    "message": "Trying to get property 'item' of non-object",
"exception": "ErrorException",
$insert_array = [];
foreach ($request->all() as $item) {
            if (is_array($item)) {
                foreach ($item as $value) {
                    if (isset($value['action'], $value['registration_record_id'], $value['mark']) && $value['action'] === 'store') {
                        $insert_array[] = [
                            'subject_quiz_id' => $request->subject_quiz_id,
                            'registration_record_id' => $value['registration_record_id'],
                            'mark' => $value['mark'],
                        ];
                    }
                }
            }
        }
dd($insert_array);