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 5
5
use Illuminate \Support \Arr ;
6
6
use Illuminate \Support \Str ;
7
7
use Illuminate \Support \Fluent ;
8
+ use Yajra \DataTables \Html \Options \Plugins \SearchPanes ;
8
9
9
10
/**
10
11
* @property string data
19
20
*/
20
21
class Column extends Fluent
21
22
{
23
+ use SearchPanes;
24
+
22
25
/**
23
26
* @param array $attributes
24
27
*/
@@ -101,7 +104,7 @@ public function orderable(bool $flag = true)
101
104
102
105
return $ this ;
103
106
}
104
-
107
+
105
108
/**
106
109
* Set column responsive priority.
107
110
*
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
27
27
use Options \Plugins \RowReorder;
28
28
use Options \Plugins \Scroller;
29
29
use Options \Plugins \Select;
30
+ use Options \Plugins \SearchPanes;
30
31
31
32
/**
32
33
* Set deferLoading option value.
Original file line number Diff line number Diff line change 5
5
use Illuminate \Support \Collection ;
6
6
use Illuminate \Support \Str ;
7
7
use Yajra \DataTables \Html \Column ;
8
+ use Illuminate \Contracts \Support \Arrayable ;
8
9
9
10
/**
10
11
* DataTables - Columns option builder.
@@ -16,17 +17,47 @@ trait HasColumns
16
17
/**
17
18
* Set columnDefs option value.
18
19
*
19
- * @param array $value
20
+ * @param mixed $value
20
21
* @return $this
21
22
* @see https://datatables.net/reference/option/columnDefs
22
23
*/
23
- public function columnDefs (array $ value )
24
+ public function columnDefs ($ value )
24
25
{
26
+ if (is_callable ($ value )) {
27
+ $ value = app ()->call ($ value );
28
+ }
29
+
30
+ if ($ value instanceof Arrayable) {
31
+ $ value = $ value ->toArray ();
32
+ }
33
+
25
34
$ this ->attributes ['columnDefs ' ] = $ value ;
26
35
27
36
return $ this ;
28
37
}
29
38
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
+
30
61
/**
31
62
* Set columns option value.
32
63
*
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