getMessage(), ['exception' => $e]); return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); } } /** * Created By : sayali parab * Created at : 03 July 2024 * Use : To download the excel. */ // public function exportReports(Request $request) // { // $reportType = $request->input('reportType'); // $states = $request->input('states'); // $restaurants = $request->input('restaurants', []); // $startDate = $request->input('startDate'); // $endDate = $request->input('endDate'); // return Excel::download(new ReportExport($reportType, $states, $startDate, $endDate, $restaurants), 'report.xlsx'); // } // public function exportReports(Request $request) // { // // dd($request->all()); // $reportType = $request->input('reportType'); // $states = $request->input('states'); // $restaurants = $request->input('restaurants', []); // $startDate = $request->input('startDate'); // $endDate = $request->input('endDate'); // try { // return Excel::download(new ReportExports($reportType, $states, $startDate, $endDate, $restaurants), 'report.xlsx'); // } catch (\Exception $e) { // // Log the error for debugging // \Log::error('Export failed: ' . $e->getMessage()); // return response()->json(['error' => 'Export failed. Something went wrong.'], 500); // } // } public function exportReport(Request $request) { // dd($request->all()); $reportType = $request->input('reportType'); $states = $request->input('states'); $restaurants = $request->input('restaurants', []); $startDate = $request->input('startDate'); $endDate = $request->input('endDate'); try { return Excel::download(new ExportReports($reportType, $states, $startDate, $endDate, $restaurants), 'reports.Xlsx'); } catch (\Exception $e) { \Log::error('Export failed: ' . $e->getMessage()); \Log::error('Stack trace: ' . $e->getTraceAsString()); return response()->json(['error' => 'Export failed. Something went wrong.'], 500); } } }