Skip to content

Commit d89ad07

Browse files
committed
Update other templates
1 parent 3f032c6 commit d89ad07

File tree

6 files changed

+44
-21
lines changed

6 files changed

+44
-21
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "deltasystems/laravel-livewire-tables",
2+
"name": "rappasoft/laravel-livewire-tables",
33
"description": "A dynamic table component for Laravel Livewire",
44
"keywords": [
55
"rappasoft",

resources/views/bootstrap-4/includes/table.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
@forelse ($rows as $index => $row)
9494
<x-livewire-tables::bs4.table.row
9595
wire:loading.class.delay="text-muted"
96-
wire:key="table-row-{{ $row->{$primaryKey} }}"
96+
wire:key="table-row-{{ md5(mt_rand()) }}-{{ $row->{$this->parseField($primaryKey)} }}"
9797
wire:sortable.item="{{ $row->{$primaryKey} }}"
9898
:reordering="$reordering"
9999
:url="method_exists($this, 'getTableRowUrl') ? $this->getTableRowUrl($row) : ''"
@@ -115,7 +115,7 @@
115115
<input
116116
wire:model="selected"
117117
wire:loading.attr.delay="disabled"
118-
value="{{ $row->{\Rappasoft\LaravelLivewireTables\Utilities\ColumnUtilities::parseField($primaryKey)} }}"
118+
value="{{ $row->{$this->parseField($primaryKey)} }}"
119119
onclick="event.stopPropagation();return true;"
120120
type="checkbox"
121121
/>

resources/views/bootstrap-5/includes/table.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class="form-check-input"
9494
@forelse ($rows as $index => $row)
9595
<x-livewire-tables::bs5.table.row
9696
wire:loading.class.delay="text-muted"
97-
wire:key="table-row-{{ $row->{$primaryKey} }}"
97+
wire:key="table-row-{{ md5(mt_rand()) }}-{{ $row->{$this->parseField($primaryKey)} }}"
9898
wire:sortable.item="{{ $row->{$primaryKey} }}"
9999
:reordering="$reordering"
100100
:url="method_exists($this, 'getTableRowUrl') ? $this->getTableRowUrl($row) : ''"
@@ -116,7 +116,7 @@ class="form-check-input"
116116
<input
117117
wire:model="selected"
118118
wire:loading.attr.delay="disabled"
119-
value="{{ $row->{\Rappasoft\LaravelLivewireTables\Utilities\ColumnUtilities::parseField($primaryKey)} }}"
119+
value="{{ $row->{$this->parseField($primaryKey)} }}"
120120
onclick="event.stopPropagation();return true;"
121121
class="form-check-input"
122122
type="checkbox"

resources/views/tailwind/includes/table.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class="rounded border-gray-300 text-indigo-600 shadow-sm transition duration-150
9696
@forelse ($rows as $index => $row)
9797
<x-livewire-tables::table.row
9898
wire:loading.class.delay="opacity-50 dark:bg-gray-900 dark:opacity-60"
99-
wire:key="table-row-{{ md5(rand()) }}-{{ $row->{\Rappasoft\LaravelLivewireTables\Utilities\ColumnUtilities::parseField($primaryKey)} }}"
99+
wire:key="table-row-{{ md5(mt_rand()) }}-{{ $row->{$this->parseField($primaryKey)} }}"
100100
wire:sortable.item="{{ $row->{$primaryKey} }}"
101101
:reordering="$reordering"
102102
:url="method_exists($this, 'getTableRowUrl') ? $this->getTableRowUrl($row) : ''"
@@ -125,7 +125,7 @@ class="rounded border-gray-300 text-indigo-600 shadow-sm transition duration-150
125125
<input
126126
wire:model="selected"
127127
wire:loading.attr.delay="disabled"
128-
value="{{ $row->{\Rappasoft\LaravelLivewireTables\Utilities\ColumnUtilities::parseField($primaryKey)} }}"
128+
value="{{ $row->{$this->parseField($primaryKey)} }}"
129129
onclick="event.stopPropagation();return true;"
130130
type="checkbox"
131131
class="rounded border-gray-300 text-indigo-600 shadow-sm transition duration-150 ease-in-out focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 dark:bg-gray-900 dark:text-white dark:border-gray-600 dark:hover:bg-gray-600 dark:focus:bg-gray-600"

src/DataTableComponent.php

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Database\Eloquent\Builder;
66
use Illuminate\Database\Eloquent\Relations\Relation;
77
use Livewire\Component;
8+
use Rappasoft\LaravelLivewireTables\Traits\ComponentHelpers;
89
use Rappasoft\LaravelLivewireTables\Traits\WithBulkActions;
910
use Rappasoft\LaravelLivewireTables\Traits\WithColumnSelect;
1011
use Rappasoft\LaravelLivewireTables\Traits\WithCustomPagination;
@@ -23,6 +24,7 @@
2324
*/
2425
abstract class DataTableComponent extends Component
2526
{
27+
use ComponentHelpers;
2628
use WithBulkActions;
2729
use WithColumnSelect;
2830
use WithCustomPagination;
@@ -226,18 +228,4 @@ public function render()
226228
'bulkActions' => $this->bulkActions,
227229
]);
228230
}
229-
230-
/**
231-
* Get a column object by its field
232-
*
233-
* @param string $column
234-
*
235-
* @return mixed
236-
*/
237-
protected function getColumn(string $column)
238-
{
239-
return collect($this->columns())
240-
->where('column', $column)
241-
->first();
242-
}
243231
}

src/Traits/ComponentHelpers.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace Rappasoft\LaravelLivewireTables\Traits;
4+
5+
use Rappasoft\LaravelLivewireTables\Utilities\ColumnUtilities;
6+
7+
/**
8+
* Trait ComponentHelpers.
9+
*/
10+
trait ComponentHelpers
11+
{
12+
/**
13+
* Get a column object by its field
14+
*
15+
* @param string $column
16+
*
17+
* @return mixed
18+
*/
19+
protected function getColumn(string $column)
20+
{
21+
return collect($this->columns())
22+
->where('column', $column)
23+
->first();
24+
}
25+
26+
/**
27+
* @param string $field
28+
*
29+
* @return string
30+
*/
31+
protected function parseField(string $field): string
32+
{
33+
return ColumnUtilities::parseField($field);
34+
}
35+
}

0 commit comments

Comments
 (0)