Completed
Push — master ( 942e44...03fbcf )
by Song
03:21
created

ExcelExporter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 40
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A headings() 0 4 1
A query() 0 4 1
A export() 0 6 1
1
<?php
2
3
namespace Encore\Admin\Grid\Exporters;
4
5
use Maatwebsite\Excel\Concerns\Exportable;
6
use Maatwebsite\Excel\Concerns\FromQuery;
7
use Maatwebsite\Excel\Concerns\WithHeadings;
8
9
abstract class ExcelExporter extends AbstractExporter implements FromQuery, WithHeadings
10
{
11
    use Exportable;
12
13
    /**
14
     * @var string
15
     */
16
    protected $fileName;
17
18
    /**
19
     * @var array
20
     */
21
    protected $headings = [];
22
23
    /**
24
     * @return array
25
     */
26
    public function headings(): array
27
    {
28
        return $this->headings;
29
    }
30
31
    /**
32
     * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model
33
     */
34
    public function query()
35
    {
36
        return $this->getQuery();
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function export()
43
    {
44
        $this->download($this->fileName)->prepare(request())->send();
45
46
        exit;
47
    }
48
}