Completed
Pull Request — master (#201)
by
unknown
02:13
created

ExcelExport::setHiddenColumnsExported()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Nayjest\Grids\Components;
4
5
use App\Jobs\ExportExcel;
6
use Event;
7
use Nayjest\Grids\Components\Base\RenderableComponent;
8
use Nayjest\Grids\Grid;
9
10
class ExcelExport extends RenderableComponent
11
{
12
    private $baseName;
13
    private $date;
14
    private $config;
15
    private $showId;
16
17
    const NAME = 'excel_export';
18
    protected $template = '*.components.excel_export';
19
20
    const INPUT_PARAM = 'xlsx';
21
22
    /**
23
     * @return mixed
24
     */
25
    public function getDate()
26
    {
27
        return $this->date;
28
    }
29
30
    /**
31
     * @return mixed
32
     */
33
    public function getBaseName()
34
    {
35
        return $this->baseName;
36
    }
37
38
    /**
39
     * @param mixed $baseName
40
     */
41
    public function setBaseName($baseName)
42
    {
43
        $this->baseName = $baseName;
44
        return $this;
45
    }
46
47
    /**
48
     * @param mixed $date
49
     */
50
    public function setDate($date)
51
    {
52
        $this->date = $date;
53
        return $this;
54
    }
55
56
    public function initialize(Grid $grid)
57
    {
58
        parent::initialize($grid);
59
        $this->showId = substr(url()->current(), strrpos(url()->current(), '/' )+1);
60
        Event::listen(Grid::EVENT_PREPARE, function (Grid $grid) {
61
            if ($grid->getInputProcessor()->getValue(static::INPUT_PARAM, false)) {
62
                dispatch((new ExportExcel($this->getDate(), $grid->getConfig()->getName(), auth()->user()->id, $this->showId))->onQueue('default'));
63
            }
64
        });
65
    }
66
}