I just impliment the crud in my application And update api does not Working I dont know why. It is not throwing any error when i hit this api from postman.
public function update(int $id,Request $request)
{
// return $request->all();
$rules = [
'question' => 'required'
];
$validator = Validator::make(
$request->all(),
$rules
);
if ($validator->fails()) {
return response()->json(
[
__('messages.ERRORKEY') => $validator->errors(),
'message' => __('messages.VALIDATION_MESSAGE')
],
env('ERRORCODE', 422)
);
}
$question = Question::with('options')->find($id);
$question->update(['question' => $request->question]);
return response()->json([
"success" => true,
"message" => "Question saved successfully.",
"data" => $question
]);
}
CodePudding user response:
The required attribute is assignable from your model or not?