1 | <?php |
||
26 | class Exporter extends NewExcelFile |
||
27 | { |
||
28 | /** Current supported files type */ |
||
29 | const TYPE_CSV = 'csv'; |
||
30 | const TYPE_XLS = 'xls'; |
||
31 | const TYPE_XLSX = 'xlsx'; |
||
32 | |||
33 | /** |
||
34 | * Parameters. |
||
35 | * |
||
36 | * @var array |
||
37 | */ |
||
38 | protected $params = []; |
||
39 | |||
40 | /** |
||
41 | * Export file format. |
||
42 | * |
||
43 | * @var string |
||
44 | */ |
||
45 | protected $format = self::TYPE_CSV; |
||
46 | |||
47 | /** |
||
48 | * Type of data to export. |
||
49 | * |
||
50 | * @var string |
||
51 | */ |
||
52 | protected $type = ''; |
||
53 | |||
54 | /** |
||
55 | * Returns the parameters. |
||
56 | * |
||
57 | * @param string $key |
||
58 | * |
||
59 | * @return mixed|array |
||
60 | */ |
||
61 | 4 | public function getParams($key = null) |
|
69 | |||
70 | /** |
||
71 | * Start importing. |
||
72 | * |
||
73 | * @param string $className |
||
74 | * @param string $format |
||
75 | * @param array $params |
||
76 | * |
||
77 | * @return array['full', 'path', 'file', 'title', 'ext'] |
||
|
|||
78 | */ |
||
79 | 4 | public function exportFile($className, $format = self::TYPE_CSV, array $params = []) |
|
80 | { |
||
81 | 4 | $params['route'] = $this->app->request->route()->parameters(); |
|
82 | 4 | $this->format = $format; |
|
83 | 4 | $this->params = $params; |
|
84 | 4 | $this->type = $className; |
|
85 | |||
86 | // Update file name |
||
87 | 4 | $this->setFileName($this->getFilename()); |
|
88 | |||
89 | // Start exporting |
||
90 | 4 | $this->handle($className); |
|
91 | |||
92 | // Store file and return info |
||
93 | 4 | return $this->store($format, false, true); |
|
94 | } |
||
95 | |||
96 | /** |
||
97 | * Returns export file name. |
||
98 | * |
||
99 | * @return string |
||
100 | */ |
||
101 | 4 | public function getFilename() |
|
105 | |||
106 | /** |
||
107 | * Construct the export class full name. |
||
108 | * |
||
109 | * @param string $type |
||
110 | * |
||
111 | * @return string |
||
112 | * |
||
113 | * @throws LaravelExcelException |
||
114 | */ |
||
115 | 4 | protected function getHandlerClassName($type) |
|
126 | } |
||
127 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.