TransactionExport.php 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace App\Exports;
  3. use App\Models\Transaction;
  4. use Illuminate\Http\Request;
  5. use Maatwebsite\Excel\Concerns\FromCollection;
  6. use Maatwebsite\Excel\Concerns\ShouldAutoSize;
  7. class TransactionExport implements ShouldAutoSize, FromCollection
  8. {
  9. public function __construct(private Request $request)
  10. {}
  11. public function collection()
  12. {
  13. $transaction = Transaction::filter($this->request->only('startDate', 'endDate', 'outlet'))->get();
  14. return $transaction;
  15. }
  16. // public function view(): View
  17. // {
  18. // $startDate = $this->request->startDate;
  19. // $endDate = $this->request->endDate;
  20. // $mutations = Mutation::filter($startDate, $endDate)->get();
  21. // return inertia('excel.dashboard.payment-report.index', [
  22. // 'mutations' => $mutations,
  23. // 'startDate' => Carbon::parse($startDate)->format('d/m/Y'),
  24. // 'endDate' => Carbon::parse($endDate)->subDay()->format('d/m/Y'),
  25. // ]);
  26. // }
  27. // public function styles(Worksheet $sheet)
  28. // {
  29. // $lastRow = $sheet->getHighestDataRow();
  30. // $lastSecondRow = $lastRow - 1;
  31. // $sheet->getRowDimension($lastSecondRow)->setRowHeight(16);
  32. // return [
  33. // 1 => [
  34. // 'font' => ['bold' => true, 'size' => 16],
  35. // 'alignment' => ['vertical' => 'center', 'horizontal' => 'center'],
  36. // ],
  37. // 3 => ['font' => ['bold' => true]],
  38. // $lastSecondRow => ['font' => ['bold' => true, 'size' => 12]],
  39. // $lastRow => [
  40. // 'font' => ['bold' => true, 'size' => 12],
  41. // 'alignment' => ['horizontal' => 'left'],
  42. // ],
  43. // ];
  44. // }
  45. }