public function update(Request $request, $id) { if (!$request->body or !$request->user_id) { return response(['error' => ['message' => 'Please Provide Both body and user_id']], 422); } $joke = Joke::find($id); $joke->body = $request->body; $joke->user_id = $request->user_id; $joke->save(); return response(['message' => 'Joke Updated Succesfully']); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { if (!$request->body || !$request->user_id) { return Response::json(['error' => ['message' => 'Please provide both body and user_id']], 422); } $joke = Joke::find($id); $joke->body = $request->body; $joke->user_id = $request->user_id; $joke->save(); return Response::json(['message' => 'Joke updated successfully']); }