Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. public function export_pdf()
  2. {
  3. if(Auth::user()->campus_id == 0){
  4. $processes = Process::join('bags','processes.bag_id', '=', 'bags.id')
  5. ->join('stations','processes.station_id', '=', 'stations.id')
  6. ->select('bags.*','stations.*','processes.*')
  7. ->where('stations.campus_id', Session::get('test'))
  8. ->orderBy('processes.id', 'desc')
  9. ->get();
  10.  
  11.  
  12. // Send data to the view using loadView function of PDF facade
  13. $pdf = PDF::loadView('collectionReportspdf', compact('processes'));
  14. // If you want to store the generated pdf to the server then you can use the store function
  15. $pdf->save(storage_path().'_filename.pdf');
  16. // Finally, you can download the file using download function
  17. return $pdf->download('reports.pdf');
  18. }
  19. else{
  20. $processes = Process::join('bags','processes.bag_id', '=', 'bags.id')
  21. ->join('stations','processes.station_id', '=', 'stations.id')
  22. ->select('bags.*','stations.*','processes.*')
  23. ->where('stations.campus_id', Auth::user()->campus_id)
  24. ->orderBy('processes.id', 'desc')
  25. ->get();
  26.  
  27.  
  28. // Send data to the view using loadView function of PDF facade
  29. $pdf = PDF::loadView('collectionReportspdf', compact('processes'));
  30. // If you want to store the generated pdf to the server then you can use the store function
  31. $pdf->save(storage_path().'_filename.pdf');
  32. // Finally, you can download the file using download function
  33. return $pdf->download('reports.pdf');
  34. }
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement