/** * Show all groups. * * Get a JSON representation of all the registered groups. * * @Get("/") * @Response(200, body={{"id": 1, "name": "Website Committee", * "officer_id": 1, "officer_url": "/officers/1", * "url": "/groups/1"}}) * @return Response */ public function index(Request $request) { $queryParameters = array_filter($request->only(['name'])); $groups = Group::query(); if (array_key_exists('name', $queryParameters)) { $groups->where('name', 'like', $queryParameters['name']); } return response()->json($groups->paginate()); }