1 | <?php |
||||
2 | |||||
3 | namespace Itstructure\GridView\Columns; |
||||
4 | |||||
5 | use Itstructure\GridView\Filters\StubFilter; |
||||
6 | use Itstructure\GridView\Traits\Configurable; |
||||
7 | |||||
8 | /** |
||||
9 | * Class CheckboxColumn. |
||||
10 | * @package Itstructure\GridView\Columns |
||||
11 | */ |
||||
12 | class CheckboxColumn extends BaseColumn |
||||
13 | { |
||||
14 | use Configurable; |
||||
15 | |||||
16 | /** |
||||
17 | * @var string |
||||
18 | */ |
||||
19 | protected $field; |
||||
20 | |||||
21 | /** |
||||
22 | * @var bool|callable |
||||
23 | */ |
||||
24 | protected $display = true; |
||||
25 | |||||
26 | /** |
||||
27 | * ActionColumn constructor. |
||||
28 | * @param array $config |
||||
29 | */ |
||||
30 | public function __construct(array $config) |
||||
31 | { |
||||
32 | $this->loadConfig($config); |
||||
33 | |||||
34 | $this->filter = new StubFilter(); |
||||
35 | } |
||||
36 | |||||
37 | /** |
||||
38 | * @return string |
||||
39 | */ |
||||
40 | public function getLabel(): string |
||||
41 | { |
||||
42 | return $this->label ?? trans('grid_view::grid.deletion'); |
||||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||||
43 | } |
||||
44 | |||||
45 | /** |
||||
46 | * @param $row |
||||
47 | * @return mixed |
||||
48 | */ |
||||
49 | public function getValue($row) |
||||
50 | { |
||||
51 | return $row->{$this->attribute} ?? ''; |
||||
52 | } |
||||
53 | |||||
54 | /** |
||||
55 | * @param $row |
||||
56 | * @return array|string |
||||
57 | */ |
||||
58 | public function render($row) |
||||
59 | { |
||||
60 | if ($this->display === false) { |
||||
61 | return view('grid_view::columns.checkbox-stub')->render(); |
||||
62 | } |
||||
63 | |||||
64 | if (is_callable($this->display) && !call_user_func($this->display, $row)) { |
||||
0 ignored issues
–
show
It seems like
$this->display can also be of type true ; however, parameter $callback of call_user_func() does only seem to accept callable , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
65 | return view('grid_view::columns.checkbox-stub')->render(); |
||||
66 | } |
||||
67 | |||||
68 | return view('grid_view::columns.checkbox', [ |
||||
69 | 'field' => $this->field, |
||||
70 | 'value' => $this->getValue($row), |
||||
71 | ])->render(); |
||||
72 | } |
||||
73 | } |
||||
74 |