1111 */
1212trait Responsive
1313{
14- /**
15- * Set responsive option value.
16- *
17- * @param bool|array $value
18- * @return $this
19- * @see https://datatables.net/reference/option/responsive
20- */
21- public function responsive (bool |array $ value = true ): static
22- {
23- $ this ->attributes ['responsive ' ] = $ value ;
24-
25- return $ this ;
26- }
27-
2814 /**
2915 * Set responsive breakpoints option value.
3016 *
@@ -38,15 +24,21 @@ public function responsiveBreakpoints(array $value): static
3824 }
3925
4026 /**
41- * Set responsive details option value.
27+ * Set responsive option value.
4228 *
4329 * @param bool|array $value
4430 * @return $this
45- * @see https://datatables.net/reference/option/responsive.details
31+ * @see https://datatables.net/reference/option/responsive
4632 */
47- public function responsiveDetails (bool |array $ value ): static
33+ public function responsive (bool |array $ value = true ): static
4834 {
49- return $ this ->responsive (['details ' => $ value ]);
35+ if (is_array ($ value )) {
36+ $ this ->attributes ['responsive ' ] = array_merge ((array ) $ this ->attributes ['responsive ' ], $ value );
37+ } else {
38+ $ this ->attributes ['responsive ' ] = $ value ;
39+ }
40+
41+ return $ this ;
5042 }
5143
5244 /**
@@ -61,6 +53,25 @@ public function responsiveDetailsDisplay(array|string $value): static
6153 return $ this ->responsiveDetails (['display ' => $ value ]);
6254 }
6355
56+ /**
57+ * Set responsive details option value.
58+ *
59+ * @param bool|array $value
60+ * @return $this
61+ * @see https://datatables.net/reference/option/responsive.details
62+ */
63+ public function responsiveDetails (bool |array $ value ): static
64+ {
65+ $ responsive = (array ) $ this ->getResponsive ();
66+ if (is_array ($ value )) {
67+ $ responsive ['details ' ] = array_merge ((array ) ($ responsive ['details ' ] ?? []), $ value );
68+ } else {
69+ $ responsive ['details ' ] = $ value ;
70+ }
71+
72+ return $ this ->responsive ($ responsive );
73+ }
74+
6475 /**
6576 * Set responsive details renderer option value.
6677 *
@@ -108,4 +119,17 @@ public function responsiveOrthogonal(string $value): static
108119 {
109120 return $ this ->responsive (['orthogonal ' => $ value ]);
110121 }
122+
123+ /**
124+ * @param string|null $key
125+ * @return mixed
126+ */
127+ public function getResponsive (string $ key = null ): mixed
128+ {
129+ if (is_null ($ key )) {
130+ return $ this ->attributes ['responsive ' ] ?? true ;
131+ }
132+
133+ return $ this ->attributes ['responsive ' ][$ key ] ?? false ;
134+ }
111135}
0 commit comments