/** * @param $comment_id * * @return array */ public function rating($comment_id) { // Get ratings $ratings = UserCommentRating::select(['rating', \DB::raw('COUNT(*) AS numRatings')])->where('comment_id', $comment_id)->groupBy('rating')->get()->toArray(); if (!$ratings) { return ResponseHelper::write(404, 1000, 'The requested comment does not exist.'); } // Get transformer $transformer = new UserCommentRatingTransformer(); // Return transformed collection return $transformer->transformCollection($ratings); }