/** * Report a comment, photo, restaurant, or review * * @param Request $request * @return Response */ public function addAction(Request $request) { $json_return = array(); $data = $request->json()->get('Report'); if ($data['type'] == CONSTANTS::PHOTO) { $photo = Photos::find($data['type_id']); if (!$photo) { $message = 'Photo not found or already deleted'; return showErrorResponse($message, HTTP_ACCEPTED, CONSTANTS::ERROR_CODE_PHOTO_MISSING); } $is_existing_photo_report = Reported::isExistingPhotoReport($data['type_id'], $data['user_id']); if ($is_existing_photo_report) { $message = 'You have already reported this photo'; return showErrorResponse($message, HTTP_ACCEPTED, CONSTANTS::ERROR_CODE_REPORTED_ALREADY); } } try { $report = new Reported(); $report_object = $report->addReport($data); $json_return[KeyParser::data] = ModelFormatter::reportFormat($report_object); } catch (\Exception $e) { return showErrorResponse($e->getMessage()); } return response()->json($json_return); }
/** * Update report status * * @param $reported_id * @param $report_status */ public static function updateReportStatus($reported_id, $report_status) { $report = new Reported(); $report->where('id', $reported_id)->update(['report_status' => $report_status]); }