|
12 | 12 | trait RowReorder |
13 | 13 | { |
14 | 14 | /** |
15 | | - * Set rowReorder option value. |
| 15 | + * Set rowReorder dataSrc option value. |
16 | 16 | * |
17 | | - * @param bool|array $value |
| 17 | + * @param array|int $value |
18 | 18 | * @return $this |
19 | | - * @see https://datatables.net/reference/option/rowReorder |
| 19 | + * @see https://datatables.net/reference/option/rowReorder.dataSrc |
20 | 20 | */ |
21 | | - public function rowReorder(bool|array $value = true): static |
| 21 | + public function rowReorderDataSrc(array|int $value = 0): static |
22 | 22 | { |
23 | | - $this->attributes['rowReorder'] = $value; |
24 | | - |
25 | | - return $this; |
| 23 | + return $this->rowReorder(['dataSrc' => $value]); |
26 | 24 | } |
27 | 25 |
|
28 | 26 | /** |
29 | | - * Set rowReorder dataSrc option value. |
| 27 | + * Set rowReorder option value. |
30 | 28 | * |
31 | | - * @param array|int $value |
| 29 | + * @param bool|array $value |
32 | 30 | * @return $this |
33 | | - * @see https://datatables.net/reference/option/rowReorder.dataSrc |
| 31 | + * @see https://datatables.net/reference/option/rowReorder |
34 | 32 | */ |
35 | | - public function rowReorderDataSrc(array|int $value = 0): static |
| 33 | + public function rowReorder(bool|array $value = true): static |
36 | 34 | { |
37 | | - return $this->rowReorder(['dataSrc' => $value]); |
| 35 | + if (is_array($value)) { |
| 36 | + $this->attributes['rowReorder'] = array_merge((array) $this->attributes['rowReorder'], $value); |
| 37 | + } else { |
| 38 | + $this->attributes['rowReorder'] = $value; |
| 39 | + } |
| 40 | + |
| 41 | + return $this; |
38 | 42 | } |
39 | 43 |
|
40 | 44 | /** |
@@ -108,4 +112,17 @@ public function rowReorderUpdate(bool $value = true): static |
108 | 112 | { |
109 | 113 | return $this->rowReorder(['update' => $value]); |
110 | 114 | } |
| 115 | + |
| 116 | + /** |
| 117 | + * @param string|null $key |
| 118 | + * @return mixed |
| 119 | + */ |
| 120 | + public function getRowReorder(string $key = null): mixed |
| 121 | + { |
| 122 | + if (is_null($key)) { |
| 123 | + return $this->attributes['rowReorder'] ?? true; |
| 124 | + } |
| 125 | + |
| 126 | + return $this->attributes['rowReorder'][$key] ?? false; |
| 127 | + } |
111 | 128 | } |
0 commit comments