| Conditions | 2 |
| Paths | 2 |
| Total Lines | 38 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | public function export($data, $filename = '') |
||
| 17 | { |
||
| 18 | |||
| 19 | |||
| 20 | $excel = \Excel::create($filename, function($excel) use ($data) |
||
| 21 | { |
||
| 22 | |||
| 23 | $excel->sheet('export', function($sheet) use ($data) |
||
| 24 | { |
||
| 25 | |||
| 26 | $sheet->fromArray($data); |
||
| 27 | $sheet->freezeFirstRow(); |
||
| 28 | $sheet->setAutoFilter(); |
||
| 29 | $sheet->row(1, function($row) |
||
| 30 | { |
||
| 31 | $row->setValignment('middle'); |
||
| 32 | $row->setAlignment('center'); |
||
| 33 | $row->setFontColor('#ffffff'); |
||
| 34 | $row->setFont(array( |
||
| 35 | 'size' => '12', |
||
| 36 | 'bold' => true |
||
| 37 | )); |
||
| 38 | $row->setBackground('#000000'); |
||
| 39 | |||
| 40 | }); |
||
| 41 | |||
| 42 | }); |
||
| 43 | |||
| 44 | |||
| 45 | }); |
||
| 46 | |||
| 47 | if (app()->environment('testing')) |
||
| 48 | { |
||
| 49 | $excel->store('xls'); |
||
| 50 | } |
||
| 51 | |||
| 52 | $excel->export('xls')->download('xls'); |
||
| 53 | } |
||
| 54 | } |