File tree Expand file tree Collapse file tree 5 files changed +43
-20
lines changed Expand file tree Collapse file tree 5 files changed +43
-20
lines changed Original file line number Diff line number Diff line change 93
93
@forelse ($rows as $index => $row )
94
94
<x-livewire-tables::bs4 .table.row
95
95
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) } } }"
97
97
wire:sortable.item =" {{ $row -> {$primaryKey } } }"
98
98
:reordering =" $reordering"
99
99
:url =" method_exists($this, 'getTableRowUrl') ? $this->getTableRowUrl($row) : ''"
115
115
<input
116
116
wire:model =" selected"
117
117
wire:loading.attr.delay =" disabled"
118
- value =" {{ $row -> {\ Rappasoft \ LaravelLivewireTables \ Utilities \ColumnUtilities :: parseField ($primaryKey )} } }"
118
+ value =" {{ $row -> {$this -> parseField ($primaryKey )} } }"
119
119
onclick =" event.stopPropagation();return true;"
120
120
type =" checkbox"
121
121
/>
Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ class="form-check-input"
94
94
@forelse ($rows as $index => $row )
95
95
<x-livewire-tables::bs5 .table.row
96
96
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) } } }"
98
98
wire:sortable.item =" {{ $row -> {$primaryKey } } }"
99
99
:reordering =" $reordering"
100
100
:url =" method_exists($this, 'getTableRowUrl') ? $this->getTableRowUrl($row) : ''"
@@ -116,7 +116,7 @@ class="form-check-input"
116
116
<input
117
117
wire:model =" selected"
118
118
wire:loading.attr.delay =" disabled"
119
- value =" {{ $row -> {\ Rappasoft \ LaravelLivewireTables \ Utilities \ColumnUtilities :: parseField ($primaryKey )} } }"
119
+ value =" {{ $row -> {$this -> parseField ($primaryKey )} } }"
120
120
onclick =" event.stopPropagation();return true;"
121
121
class =" form-check-input"
122
122
type =" checkbox"
Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ class="rounded border-gray-300 text-indigo-600 shadow-sm transition duration-150
96
96
@forelse ($rows as $index => $row )
97
97
<x-livewire-tables::table .row
98
98
wire:loading.class.delay =" opacity-50 dark:bg-gray-900 dark:opacity-60"
99
- wire:key =" table-row-{{ $row -> {$primaryKey } } }"
99
+ wire:key =" table-row-{{ md5 ( mt_rand ()) } } - {{ $row -> {$this -> parseField ( $ primaryKey) } } }"
100
100
wire:sortable.item =" {{ $row -> {$primaryKey } } }"
101
101
:reordering =" $reordering"
102
102
: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
125
125
<input
126
126
wire:model =" selected"
127
127
wire:loading.attr.delay =" disabled"
128
- value =" {{ $row -> {\ Rappasoft \ LaravelLivewireTables \ Utilities \ColumnUtilities :: parseField ($primaryKey )} } }"
128
+ value =" {{ $row -> {$this -> parseField ($primaryKey )} } }"
129
129
onclick =" event.stopPropagation();return true;"
130
130
type =" checkbox"
131
131
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"
Original file line number Diff line number Diff line change 5
5
use Illuminate \Database \Eloquent \Builder ;
6
6
use Illuminate \Database \Eloquent \Relations \Relation ;
7
7
use Livewire \Component ;
8
+ use Rappasoft \LaravelLivewireTables \Traits \ComponentHelpers ;
8
9
use Rappasoft \LaravelLivewireTables \Traits \WithBulkActions ;
9
10
use Rappasoft \LaravelLivewireTables \Traits \WithColumnSelect ;
10
11
use Rappasoft \LaravelLivewireTables \Traits \WithCustomPagination ;
23
24
*/
24
25
abstract class DataTableComponent extends Component
25
26
{
27
+ use ComponentHelpers;
26
28
use WithBulkActions;
27
29
use WithColumnSelect;
28
30
use WithCustomPagination;
@@ -226,18 +228,4 @@ public function render()
226
228
'bulkActions ' => $ this ->bulkActions ,
227
229
]);
228
230
}
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
- }
243
231
}
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments