RowAction.php
1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
namespace Dcat\Admin\Grid;
use Illuminate\Support\Fluent;
abstract class RowAction extends GridAction
{
/**
* @var Fluent
*/
protected $row;
/**
* @var Column
*/
protected $column;
/**
* Get primary key value of current row.
*
* @return mixed
*/
public function getKey()
{
if ($this->row) {
return $this->row->{$this->parent->getKeyName()};
}
return parent::getKey();
}
/**
* Set row model.
*
* @param mixed $key
* @return \Illuminate\Database\Eloquent\Model|mixed
*/
public function row($key = null)
{
if (func_num_args() == 0) {
return $this->row;
}
return $this->row->{$key};
}
/**
* Set row model.
*
* @param Fluent|\Illuminate\Database\Eloquent\Model $row
* @return $this
*/
public function setRow($row)
{
$this->row = $row;
return $this;
}
public function getRow()
{
return $this->row;
}
/**
* @param Column $column
* @return $this
*/
public function setColumn(Column $column)
{
$this->column = $column;
return $this;
}
}