/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index(Request $request) { $partecipanti = Partecipante::latest()->get(); if ($request->ajax() || $request->wantsJson()) { return new JsonResponse($partecipanti); } return view('partecipanti.index', compact('partecipanti')); }