У меня проблема в laravel-dompdf.Я думаю, что мой код правильный, и я не знаю, почему он направляет на белую страницу вместо загрузки PDF.Он работает в другом контроллере, но здесь нет.
Мой код в моем контроллере:
public function export_pdf()
{
if(Auth::user()->campus_id == 0){
$processes = Process::join('bags','processes.bag_id', '=', 'bags.id')
->join('stations','processes.station_id', '=', 'stations.id')
->select('bags.*','stations.*','processes.*')
->where('stations.campus_id', Session::get('test'))
->orderBy('processes.id', 'desc')
->get();
// Send data to the view using loadView function of PDF facade
$pdf = PDF::loadView('collectionReportspdf', compact('processes'));
// If you want to store the generated pdf to the server then you can use the store function
$pdf->save(storage_path().'_filename.pdf');
// Finally, you can download the file using download function
return $pdf->download('reports.pdf');
}
else{
$processes = Process::join('bags','processes.bag_id', '=', 'bags.id')
->join('stations','processes.station_id', '=', 'stations.id')
->select('bags.*','stations.*','processes.*')
->where('stations.campus_id', Auth::user()->campus_id)
->orderBy('processes.id', 'desc')
->get();
// Send data to the view using loadView function of PDF facade
$pdf = PDF::loadView('collectionReportspdf', compact('processes'));
// If you want to store the generated pdf to the server then you can use the store function
$pdf->save(storage_path().'_filename.pdf');
// Finally, you can download the file using download function
return $pdf->download('reports.pdf');
}
}