exportSpecific

This commit is contained in:
sayaliparab
2024-07-03 19:30:35 +05:30
parent 9721378c66
commit cd77a330d9
5 changed files with 92 additions and 52 deletions

View File

@@ -8,8 +8,7 @@ use App\Models\ManageState;
use Illuminate\Support\Facades\Log;
use Maatwebsite\Excel\Facades\Excel;
use App\Exports\ReportExport;
use App\Models\ManageRestaurant;
class ManageReportsController extends Controller
{
@@ -18,7 +17,8 @@ class ManageReportsController extends Controller
{
try {
$states = ManageState::all();
return view('Admin.pages.manage_reports.manage_reports', compact('states'));
$restaurants = ManageRestaurant::all();
return view('Admin.pages.manage_reports.manage_reports', compact('states','restaurants'));
} catch (\Exception $e) {
Log::error("An error occurred in " . __METHOD__ . ": " . $e->getMessage(), ['exception' => $e]);
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
@@ -40,10 +40,12 @@ 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), 'report.xlsx');
return Excel::download(new ReportExport($reportType, $states, $startDate, $endDate, $restaurants), 'report.xlsx');
}
}