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
|
|
|
*/ |
16
|
|
|
public function pdf($filename, $response, $paperorientation, $papersize) |
17
|
|
|
{ |
18
|
|
|
$view = view('crudbooster::export', $response)->render(); |
19
|
|
|
$pdf = app('dompdf.wrapper'); |
20
|
|
|
$pdf->loadHTML($view); |
|
|
|
|
21
|
|
|
$pdf->setPaper($papersize, $paperorientation); |
|
|
|
|
22
|
|
|
|
23
|
|
|
return $pdf->stream($filename.'.pdf'); |
|
|
|
|
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @param $filename |
28
|
|
|
* @param $response |
29
|
|
|
* @param $orientation |
30
|
|
|
*/ |
31
|
|
|
public function xls($filename, $response, $orientation) |
32
|
|
|
{ |
33
|
|
|
return $this->exportExcelAs($filename, $response, $orientation, 'xls'); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @param $filename |
38
|
|
|
* @param $response |
39
|
|
|
* @param $orientation |
40
|
|
|
*/ |
41
|
|
|
public function csv($filename, $response, $orientation) |
42
|
|
|
{ |
43
|
|
|
return $this->exportExcelAs($filename, $response, $orientation, 'csv'); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @param $filename |
48
|
|
|
* @param $response |
49
|
|
|
* @param $orientation |
50
|
|
|
* @param $fmt |
51
|
|
|
* @return mixed |
52
|
|
|
*/ |
53
|
|
|
private function exportExcelAs($filename, $response, $orientation, $fmt) |
54
|
|
|
{ |
55
|
|
|
return Excel::create($filename, function ($excel) use ($response, $orientation, $filename) { |
56
|
|
|
$excel->setTitle($filename)->setCreator("crudbooster.com")->setCompany(cbGetsetting('appname')); |
57
|
|
|
$excel->sheet($filename, function ($sheet) use ($response, $orientation) { |
58
|
|
|
$sheet->setOrientation($orientation); |
59
|
|
|
$sheet->loadview('crudbooster::export', $response); |
60
|
|
|
}); |
61
|
|
|
})->export($fmt); |
62
|
|
|
} |
63
|
|
|
} |
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.