Heim > Fragen und Antworten > Hauptteil
P粉1569834462023-08-26 00:38:39
首先创建一个实例。但我认为这不是真正的问题。
$newGrade = (new Grade())->update($grade); return [ 'status' => 'success', 'grade' => $newGrade, ];
尝试将您的方法更改如下:
$grade = Grade::findOrFail($request->id); $validatedData = $request->validate([ 'title' => 'required|string', 'slig' => 'string', 'description' => 'string', ]); $grade->update($validatedData); return [ 'status' => 'success', 'grade' => $grade, ];