File tree Expand file tree Collapse file tree 3 files changed +14
-14
lines changed
Expand file tree Collapse file tree 3 files changed +14
-14
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,13 @@ class Column
2323 */
2424 public $ hidden = false ;
2525
26+ /**
27+ * Column seachable
28+ *
29+ * @var bool
30+ */
31+ public $ forceSearch = false ;
32+
2633 /**
2734 * Callback function
2835 *
@@ -72,12 +79,12 @@ public function value($row): string
7279 /**
7380 * Set visibility of the column.
7481 */
75- public function hide (): void
82+ public function hide ($ searchable = false ): void
7683 {
7784 $ this ->hidden = true ;
85+ $ this ->forceSearch = $ searchable ;
7886 }
7987
80-
8188 /**
8289 * @return bool
8390 */
@@ -115,6 +122,6 @@ public function data(): string
115122 */
116123 public function searchValue (): string
117124 {
118- return $ this ->attr ['search ' ]['value ' ];
125+ return $ this ->attr ['search ' ]['value ' ] ?? '' ;
119126 }
120127}
Original file line number Diff line number Diff line change @@ -140,19 +140,12 @@ public function getQuery(): Query
140140 }
141141
142142 /**
143- * @param array $columns
143+ * @param string $column
144144 * @return Datatables
145145 */
146- public function hide (... $ columns ): Datatables
146+ public function hide (string $ column , $ searchable = false ): Datatables
147147 {
148- foreach ($ columns as $ column ) {
149- if (\is_array ($ column )) {
150- $ this ->hide (...$ column );
151- } else {
152- $ this ->columns ->getByName ($ column )->hide ();
153- }
154- }
155-
148+ $ this ->columns ->getByName ($ column )->hide ($ searchable );
156149 return $ this ;
157150 }
158151
Original file line number Diff line number Diff line change @@ -17,6 +17,6 @@ class GlobalSearchableColumns extends FilterIterator
1717 */
1818 public function accept (): bool
1919 {
20- return !$ this ->current ()->hidden && $ this ->current ()->isSearchable ();
20+ return ( $ this -> current ()-> forceSearch || ( !$ this ->current ()->hidden && $ this ->current ()->isSearchable ()) );
2121 }
2222}
You can’t perform that action at this time.
0 commit comments