File tree Expand file tree Collapse file tree 7 files changed +75
-7
lines changed Expand file tree Collapse file tree 7 files changed +75
-7
lines changed Original file line number Diff line number Diff line change 6
6
' text' => null ,
7
7
] )
8
8
9
+ @php
10
+ $headerAttributesList = [];
11
+ $headerAttributesList [] = [' class' => $attributes -> get (' class' )];
12
+ $headerAttributesList [] = $attributes -> get (' extraAttributes' ) ?? [];
13
+
14
+ $headerAttributes = ' ' ;
15
+ collect ($headerAttributesList )-> each (function ($item ) use (& $headerAttributes ) {
16
+ if (count ($item )) {
17
+ $headerAttributes .= collect ($item )-> map (fn ($value , $key ) => $key . ' ="' . $value . ' "' )-> implode (' ' );
18
+ }
19
+ });
20
+
21
+ @endphp
22
+
9
23
@unless ($sortingEnabled && $sortable )
10
- <th {{ $attributes -> only ( ' class ' ) } } >
24
+ <th {!! $headerAttributes ! ! } >
11
25
{{ $text ?? $slot } }
12
26
</th >
13
27
@else
14
28
<th
15
29
wire:click =" sortBy('{{ $column } } ', '{{ $text ?? $column } } ')"
16
- {{ $attributes -> only ( ' class ' ) } }
30
+ {!! $headerAttributes ! ! }
17
31
style =" cursor :pointer ;"
18
32
>
19
33
<div class =" d-flex align-items-center" >
Original file line number Diff line number Diff line change 27
27
:direction =" $column->column() ? $sorts[$column->column()] ?? null : null"
28
28
:text =" $column->text() ?? ''"
29
29
:class =" $column->class() ?? ''"
30
+ :extraAttributes =" $column->attributes()"
30
31
/>
31
32
@endif
32
33
@endif
Original file line number Diff line number Diff line change 6
6
' text' => null ,
7
7
] )
8
8
9
+ @php
10
+ $headerAttributesList = [];
11
+ $headerAttributesList [] = [' class' => $attributes -> get (' class' )];
12
+ $headerAttributesList [] = $attributes -> get (' extraAttributes' ) ?? [];
13
+
14
+ $headerAttributes = ' ' ;
15
+ collect ($headerAttributesList )-> each (function ($item ) use (& $headerAttributes ) {
16
+ if (count ($item )) {
17
+ $headerAttributes .= collect ($item )-> map (fn ($value , $key ) => $key . ' ="' . $value . ' "' )-> implode (' ' );
18
+ }
19
+ });
20
+
21
+ @endphp
22
+
9
23
@unless ($sortingEnabled && $sortable )
10
- <th {{ $attributes -> only ( ' class ' ) } } >
24
+ <th {!! $headerAttributes ! ! } >
11
25
{{ $text ?? $slot } }
12
26
</th >
13
27
@else
14
28
<th
15
29
wire:click =" sortBy('{{ $column } } ', '{{ $text ?? $column } } ')"
16
- {{ $attributes -> only ( ' class ' ) } }
30
+ {!! $headerAttributes ! ! }
17
31
style =" cursor :pointer ;"
18
32
>
19
33
<div class =" d-flex align-items-center" >
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ class="form-check-input"
28
28
:direction =" $column->column() ? $sorts[$column->column()] ?? null : null"
29
29
:text =" $column->text() ?? ''"
30
30
:class =" $column->class() ?? ''"
31
+ :extraAttributes =" $column->attributes()"
31
32
/>
32
33
@endif
33
34
@endif
Original file line number Diff line number Diff line change 6
6
' text' => null ,
7
7
] )
8
8
9
- <th
10
- {{ $attributes -> merge ([' class' => ' px-3 py-2 md:px-6 md:py-3 bg-gray-50' ])-> only (' class' ) } }
11
- >
9
+ @php
10
+ $headerAttributesList = [];
11
+ $headerAttributesList [] = [' class' => ' px-3 py-2 md:px-6 md:py-3 bg-gray-50 ' . $attributes -> get (' class' )];
12
+ $headerAttributesList [] = $attributes -> get (' extraAttributes' ) ?? [];
13
+
14
+ $headerAttributes = ' ' ;
15
+ collect ($headerAttributesList )-> each (function ($item ) use (& $headerAttributes ) {
16
+ if (count ($item )) {
17
+ $headerAttributes .= collect ($item )-> map (fn ($value , $key ) => $key . ' ="' . $value . ' "' )-> implode (' ' );
18
+ }
19
+ });
20
+
21
+ @endphp
22
+
23
+ <th {!! $headerAttributes ! !} >
12
24
@unless ($sortingEnabled && $sortable )
13
25
<span class =" block text-left text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider" >
14
26
{{ $text ?? $slot } }
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ class="rounded-md shadow-sm border-gray-300 block transition duration-150 ease-i
30
30
:direction =" $column->column() ? $sorts[$column->column()] ?? null : null"
31
31
:text =" $column->text() ?? ''"
32
32
:class =" $column->class() ?? ''"
33
+ :extraAttributes =" $column->attributes()"
33
34
/>
34
35
@endif
35
36
@endif
Original file line number Diff line number Diff line change @@ -19,6 +19,11 @@ class Column
19
19
*/
20
20
public ?string $ text = null ;
21
21
22
+ /**
23
+ * @var array
24
+ */
25
+ public array $ attributes = [];
26
+
22
27
/**
23
28
* @var bool
24
29
*/
@@ -170,6 +175,18 @@ public function addClass(string $class): self
170
175
return $ this ;
171
176
}
172
177
178
+ /**
179
+ * @param array $attributes
180
+ *
181
+ * @return $this
182
+ */
183
+ public function addAttributes (array $ attributes ): self
184
+ {
185
+ $ this ->attributes = $ attributes ;
186
+
187
+ return $ this ;
188
+ }
189
+
173
190
/**
174
191
* @return Column
175
192
*/
@@ -204,6 +221,14 @@ public function text(): ?string
204
221
return $ this ->text ;
205
222
}
206
223
224
+ /**
225
+ * @return array
226
+ */
227
+ public function attributes (): array
228
+ {
229
+ return $ this ->attributes ;
230
+ }
231
+
207
232
/**
208
233
* @param callable $callable
209
234
*
You can’t perform that action at this time.
0 commit comments