public function reportChartUser(Request $request) { $dateRange = $request->input('dateRange', false); $type = $request->input('type', 'day'); $userService = new userService(); $return = array(); $return['ok'] = 0; try { $return['data'] = $userService->getUserReport($dateRange, $type); $return['ok'] = 1; } catch (\Exception $e) { if ($request->ajax()) { $return['error'] = $e->getMessage(); } else { return view('errors.404', ['error_message' => $e->getMessage()]); } } return response()->json($return); }