Skip to content

Commit d33e4dc

Browse files
committed
render attributes (class & additionals) for th
1 parent 32440ca commit d33e4dc

File tree

3 files changed

+47
-7
lines changed

3 files changed

+47
-7
lines changed

resources/views/bootstrap-4/components/table/heading.blade.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,28 @@
66
'text' => null,
77
])
88

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+
923
@unless ($sortingEnabled && $sortable)
10-
<th {{ $attributes->only('class') }}>
24+
<th {!! $headerAttributes !!}>
1125
{{ $text ?? $slot }}
1226
</th>
1327
@else
1428
<th
1529
wire:click="sortBy('{{ $column }}', '{{ $text ?? $column }}')"
16-
{{ $attributes->only('class') }}
30+
{!! $headerAttributes !!}
1731
style="cursor:pointer;"
1832
>
1933
<div class="d-flex align-items-center">

resources/views/bootstrap-5/components/table/heading.blade.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,28 @@
66
'text' => null,
77
])
88

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+
923
@unless ($sortingEnabled && $sortable)
10-
<th {{ $attributes->only('class') }}>
24+
<th {!! $headerAttributes !!}>
1125
{{ $text ?? $slot }}
1226
</th>
1327
@else
1428
<th
1529
wire:click="sortBy('{{ $column }}', '{{ $text ?? $column }}')"
16-
{{ $attributes->only('class') }}
30+
{!! $headerAttributes !!}
1731
style="cursor:pointer;"
1832
>
1933
<div class="d-flex align-items-center">

resources/views/tailwind/components/table/heading.blade.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,21 @@
66
'text' => null,
77
])
88

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 !!}>
1224
@unless ($sortingEnabled && $sortable)
1325
<span class="block text-left text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider">
1426
{{ $text ?? $slot }}

0 commit comments

Comments
 (0)