Exemplo n.º 1
0
 /**
  * @SWG\Get(
  *     path="/ratings",
  *     description="Returns all the ratings",
  *     operationId="getRatings",
  *     tags={"ratings"},
  *     produces={"application/json"},
  *     @SWG\Parameter(
  *         description="Access token",
  *         in="header",
  *         name="Authorization",
  *         required=true,
  *         type="string"
  *     ),
  *     @SWG\Response(
  *         response=200,
  *         description="All ratings response",
  *         @SWG\Schema(
  *             type="array",
  *             @SWG\Items(ref="#/definitions/rating")
  *         ),
  *     ),
  *     @SWG\Response(
  *         response="401",
  *         description="token_not_provided/token_invalid",
  *         @SWG\Schema(
  *             ref="#/definitions/errorModel"
  *         )
  *     )
  * )
  */
 public function index(Request $request)
 {
     $filterColumns = ['user_id' => 'end_user_id', 'mastori_id' => 'mastori_id', 'rating' => 'rating', 'created_at' => 'created_at'];
     $ratings = Rating::with('mastori')->with('user')->filterColumns($filterColumns);
     if (Auth::guest() || Auth::user()->userable_type !== 'App\\Admin') {
         $ratings = $ratings->approved();
     }
     return $ratings->paginate($request->input('per_page'));
 }