1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Crocodicstudio\Crudbooster\Controllers\Helpers; |
4
|
|
|
|
5
|
|
|
use Maatwebsite\Excel\Facades\Excel; |
6
|
|
|
|
7
|
|
|
class IndexExport |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* @param $response |
11
|
|
|
* @param $paperSize |
12
|
|
|
* @param $paperOrientation |
13
|
|
|
* @param $fileName |
14
|
|
|
* @return mixed |
15
|
|
|
* @throws \Throwable |
16
|
|
|
*/ |
17
|
|
|
public function pdf($fileName, $response, $paperOrientation, $paperSize) |
18
|
|
|
{ |
19
|
|
|
$view = view('crudbooster::export', $response)->render(); |
20
|
|
|
$pdf = app('dompdf.wrapper'); |
21
|
|
|
$pdf->loadHTML($view); |
|
|
|
|
22
|
|
|
$pdf->setPaper($paperSize, $paperOrientation); |
|
|
|
|
23
|
|
|
|
24
|
|
|
return $pdf->stream($fileName.'.pdf'); |
|
|
|
|
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @param $filename |
29
|
|
|
* @param $response |
30
|
|
|
* @param $orientation |
31
|
|
|
*/ |
32
|
|
|
public function xls($filename, $response, $orientation) |
33
|
|
|
{ |
34
|
|
|
return $this->exportExcelAs($filename, $response, $orientation, 'xls'); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @param $filename |
39
|
|
|
* @param $response |
40
|
|
|
* @param $orientation |
41
|
|
|
*/ |
42
|
|
|
public function csv($filename, $response, $orientation) |
43
|
|
|
{ |
44
|
|
|
return $this->exportExcelAs($filename, $response, $orientation, 'csv'); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @param $filename |
49
|
|
|
* @param $response |
50
|
|
|
* @param $orientation |
51
|
|
|
* @param $fmt |
52
|
|
|
* @return mixed |
53
|
|
|
*/ |
54
|
|
|
private function exportExcelAs($filename, $response, $orientation, $fmt) |
55
|
|
|
{ |
56
|
|
|
return Excel::create($filename, function ($excel) use ($response, $orientation, $filename) { |
57
|
|
|
$excel->setTitle($filename)->setCreator("crudbooster.com")->setCompany(cbGetsetting('appname')); |
58
|
|
|
$excel->sheet($filename, function ($sheet) use ($response, $orientation) { |
59
|
|
|
$sheet->setOrientation($orientation); |
60
|
|
|
$sheet->loadview('crudbooster::export', $response); |
61
|
|
|
}); |
62
|
|
|
})->export($fmt); |
63
|
|
|
} |
64
|
|
|
} |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.