Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. <?php
  2.  
  3. namespace AppHttpControllers;
  4.  
  5. use IlluminateHttpRequest;
  6. use AppExportsMttRegistrationsExport;
  7. use MaatwebsiteExcelFacadesExcel;
  8.  
  9. class ExcelController extends Controller
  10. {
  11. public function export($id)
  12. {
  13. return Excel::download(new MttRegistrationsExport, 'MttRegistrations.xlsx', compact('id'));
  14. }
  15. }
  16.  
  17. <?php
  18.  
  19. namespace AppExports;
  20.  
  21. use AppMttRegistration;
  22. use MaatwebsiteExcelConcernsFromCollection;
  23.  
  24. class MttRegistrationsExport implements FromCollection
  25. {
  26. /**
  27. * @return IlluminateSupportCollection
  28. */
  29. public function collection()
  30. {
  31. return MttRegistration::where('lifeskill_id',$id)->get()([
  32. 'first_name', 'email'
  33. ]);
  34. }
  35. }
  36.  
  37. Route::get('/mtt/attendance/{id}',[
  38. 'as' => 'mtt.attendance',
  39. 'uses' => 'ExcelController@export']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement