/** * Update the testimonial. * * @param Request $request * @param Model $testimonial * * @return json */ public function update(TestimonialAdminApiRequest $request, Testimonial $testimonial) { try { $attributes = $request->all(); $testimonial->update($attributes); $testimonial = $testimonial->presenter(); $testimonial['code'] = 2005; return response()->json($testimonial)->setStatusCode(201, 'UPDATE_SUCCESS'); } catch (Exception $e) { return response()->json(['message' => $e->getMessage(), 'code' => 4005])->setStatusCode(400, 'UPDATE_ERROR'); } }
/** * Update the testimonial. * * @param Request $request * @param Model $testimonial * * @return Response */ public function update(TestimonialAdminRequest $request, Testimonial $testimonial) { try { $attributes = $request->all(); $testimonial->update($attributes); return response()->json(['message' => trans('messages.success.updated', ['Module' => trans('testimonial::testimonial.name')]), 'code' => 204, 'redirect' => trans_url('/admin/testimonial/testimonial/' . $testimonial->getRouteKey())], 201); } catch (Exception $e) { return response()->json(['message' => $e->getMessage(), 'code' => 400, 'redirect' => trans_url('/admin/testimonial/testimonial/' . $testimonial->getRouteKey())], 400); } }