Completed
Push — master ( 24b53c...2117a3 )
by Song
02:20
created

BatchAction::setId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Encore\Admin\Grid\Tools;
4
5
use Encore\Admin\Grid;
6
use Illuminate\Contracts\Support\Renderable;
7
8
abstract class BatchAction implements Renderable
9
{
10
    /**
11
     * @var int
12
     */
13
    protected $id;
14
15
    /**
16
     * @var string
17
     */
18
    protected $title;
19
20
    /**
21
     * @var string
22
     */
23
    protected $resource;
24
25
    /**
26
     * @var Grid
27
     */
28
    protected $grid;
29
30
    /**
31
     * @param $id
32
     */
33
    public function setId($id)
34
    {
35
        $this->id = $id;
36
    }
37
38
    /**
39
     * Set title for this action.
40
     *
41
     * @param string $title
42
     *
43
     * @return $this
44
     */
45
    public function setTitle($title)
46
    {
47
        $this->title = $title;
48
49
        return $this;
50
    }
51
52
    /**
53
     * @return string
54
     */
55
    public function getTitle()
56
    {
57
        return $this->title;
58
    }
59
60
    /**
61
     * @param Grid $grid
62
     */
63
    public function setGrid(Grid $grid)
64
    {
65
        $this->grid = $grid;
66
67
        $this->resource = $grid->resource();
68
    }
69
70
    /**
71
     * @return string
72
     */
73
    public function getToken()
74
    {
75
        return csrf_token();
76
    }
77
78
    /**
79
     * @param bool $dotPrefix
80
     *
81
     * @return string
82
     */
83
    public function getElementClass($dotPrefix = true)
84
    {
85
        return sprintf(
86
            '%s%s-%s',
87
            $dotPrefix ? '.' : '',
88
            $this->grid->getGridBatchName(),
89
            $this->id
90
        );
91
    }
92
93
    /**
94
     * @return string
95
     */
96
    public function render()
97
    {
98
        return $this->title;
99
    }
100
101
    /**
102
     * @return mixed
103
     */
104
    abstract public function script();
105
}
106