File tree Expand file tree Collapse file tree 2 files changed +38
-2
lines changed
Expand file tree Collapse file tree 2 files changed +38
-2
lines changed Original file line number Diff line number Diff line change @@ -16,11 +16,11 @@ trait SearchPanes
1616 /**
1717 * Set searchPane option value.
1818 *
19- * @param bool|array $value
19+ * @param array| bool|callable $value
2020 * @return $this
2121 * @see https://datatables.net/reference/option/searchPanes
2222 */
23- public function searchPanes (bool |array $ value = true ): static
23+ public function searchPanes (array | Arrayable | bool |callable $ value = true ): static
2424 {
2525 if (is_callable ($ value )) {
2626 $ value = app ()->call ($ value );
@@ -38,4 +38,17 @@ public function searchPanes(bool|array $value = true): static
3838
3939 return $ this ;
4040 }
41+
42+ /**
43+ * @param string|null $key
44+ * @return mixed
45+ */
46+ public function getSearchPanes (string $ key = null ): mixed
47+ {
48+ if (is_null ($ key )) {
49+ return $ this ->attributes ['searchPanes ' ] ?? true ;
50+ }
51+
52+ return $ this ->attributes ['searchPanes ' ][$ key ] ?? false ;
53+ }
4154}
Original file line number Diff line number Diff line change 33namespace Yajra \DataTables \Html \Tests ;
44
55use Yajra \DataTables \Html \Button ;
6+ use Yajra \DataTables \Html \SearchPane ;
67
78class BuilderOptionsPluginsTest extends TestCase
89{
@@ -255,5 +256,27 @@ public function it_has_scroller_plugin()
255256 $ this ->assertEquals (200 , $ builder ->getScroller ('serverWait ' ));
256257 }
257258
259+ /** @test */
260+ public function it_has_search_panes_plugin ()
261+ {
262+ $ builder = $ this ->getHtmlBuilder ();
263+ $ builder ->searchPanes ();
264+
265+ $ this ->assertEquals (['show ' => true ], $ builder ->getAttribute ('searchPanes ' ));
266+ $ this ->assertIsArray ($ builder ->getSearchPanes ());
258267
268+ $ builder ->searchPanes (false );
269+ $ this ->assertEquals (['show ' => false ], $ builder ->getAttribute ('searchPanes ' ));
270+
271+ $ builder ->searchPanes (['hide ' => true ]);
272+ $ this ->assertEquals (['hide ' => true ], $ builder ->getAttribute ('searchPanes ' ));
273+
274+ $ builder ->searchPanes (function () {
275+ return ['show ' => true ];
276+ });
277+ $ this ->assertEquals (['show ' => true ], $ builder ->getAttribute ('searchPanes ' ));
278+
279+ $ builder ->searchPanes (SearchPane::make ()->show ()->cascadePanes ());
280+ $ this ->assertEquals (['show ' => true , 'cascadePanes ' => true ], $ builder ->getAttribute ('searchPanes ' ));
281+ }
259282}
You can’t perform that action at this time.
0 commit comments