Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement