File tree Expand file tree Collapse file tree 7 files changed +422
-3
lines changed Expand file tree Collapse file tree 7 files changed +422
-3
lines changed Original file line number Diff line number Diff line change 55use Illuminate \Support \Arr ;
66use Illuminate \Support \Str ;
77use Illuminate \Support \Fluent ;
8+ use Yajra \DataTables \Html \Options \Plugins \SearchPanes ;
89
910/**
1011 * @property string data
1920 */
2021class Column extends Fluent
2122{
23+ use SearchPanes;
24+
2225 /**
2326 * @param array $attributes
2427 */
@@ -101,7 +104,7 @@ public function orderable(bool $flag = true)
101104
102105 return $ this ;
103106 }
104-
107+
105108 /**
106109 * Set column responsive priority.
107110 *
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Yajra \DataTables \Html ;
4+
5+ use Illuminate \Support \Fluent ;
6+
7+ class ColumnDefinition extends Fluent
8+ {
9+ use HasOptions;
10+
11+ public function targets ($ value )
12+ {
13+ $ this ->attributes ['targets ' ] = (array ) $ value ;
14+
15+ return $ this ;
16+ }
17+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Yajra \DataTables \Html ;
4+
5+ use Illuminate \Support \Collection ;
6+
7+ class ColumnDefinitions extends Collection
8+ {
9+
10+ }
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ trait HasOptions
2727 use Options \Plugins \RowReorder;
2828 use Options \Plugins \Scroller;
2929 use Options \Plugins \Select;
30+ use Options \Plugins \SearchPanes;
3031
3132 /**
3233 * Set deferLoading option value.
Original file line number Diff line number Diff line change 55use Illuminate \Support \Collection ;
66use Illuminate \Support \Str ;
77use Yajra \DataTables \Html \Column ;
8+ use Illuminate \Contracts \Support \Arrayable ;
89
910/**
1011 * DataTables - Columns option builder.
@@ -16,17 +17,47 @@ trait HasColumns
1617 /**
1718 * Set columnDefs option value.
1819 *
19- * @param array $value
20+ * @param mixed $value
2021 * @return $this
2122 * @see https://datatables.net/reference/option/columnDefs
2223 */
23- public function columnDefs (array $ value )
24+ public function columnDefs ($ value )
2425 {
26+ if (is_callable ($ value )) {
27+ $ value = app ()->call ($ value );
28+ }
29+
30+ if ($ value instanceof Arrayable) {
31+ $ value = $ value ->toArray ();
32+ }
33+
2534 $ this ->attributes ['columnDefs ' ] = $ value ;
2635
2736 return $ this ;
2837 }
2938
39+ /**
40+ * Add a columnDef option.
41+ *
42+ * @param mixed $value
43+ * @return $this
44+ * @see https://datatables.net/reference/option/columnDefs
45+ */
46+ public function addColumnDef ($ value )
47+ {
48+ if (is_callable ($ value )) {
49+ $ value = app ()->call ($ value );
50+ }
51+
52+ if ($ value instanceof Arrayable) {
53+ $ value = $ value ->toArray ();
54+ }
55+
56+ $ this ->attributes ['columnDefs ' ][] = $ value ;
57+
58+ return $ this ;
59+ }
60+
3061 /**
3162 * Set columns option value.
3263 *
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Yajra \DataTables \Html \Options \Plugins ;
4+
5+ use Yajra \DataTables \Html \SearchPane ;
6+ use Illuminate \Contracts \Support \Arrayable ;
7+
8+ /**
9+ * DataTables - Search panes plugin option builder.
10+ *
11+ * @see https://datatables.net/extensions/searchpanes
12+ * @see https://datatables.net/reference/option/searchPanes
13+ */
14+ trait SearchPanes
15+ {
16+ /**
17+ * Set searchPane option value.
18+ *
19+ * @param bool|array $value
20+ * @return $this
21+ * @see https://datatables.net/reference/option/searchPanes
22+ */
23+ public function searchPanes ($ value = true )
24+ {
25+ if (is_callable ($ value )) {
26+ $ value = app ()->call ($ value );
27+ }
28+
29+ if ($ value instanceof Arrayable) {
30+ $ value = $ value ->toArray ();
31+ }
32+
33+ if (is_bool ($ value )) {
34+ $ value = SearchPane::make ()->show ($ value )->toArray ();
35+ }
36+
37+ $ this ->attributes ['searchPanes ' ] = $ value ;
38+
39+ return $ this ;
40+ }
41+ }
You can’t perform that action at this time.
0 commit comments