P粉1569834462023-08-26 00:38:39
First create an instance. But I don't think that's the real issue.
$newGrade = (new Grade())->update($grade); return [ 'status' => 'success', 'grade' => $newGrade, ];
Try changing your method as follows:
$grade = Grade::findOrFail($request->id); $validatedData = $request->validate([ 'title' => 'required|string', 'slig' => 'string', 'description' => 'string', ]); $grade->update($validatedData); return [ 'status' => 'success', 'grade' => $grade, ];