File tree Expand file tree Collapse file tree 4 files changed +20
-0
lines changed Expand file tree Collapse file tree 4 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ All notable changes to `laravel-livewire-tables` will be documented in this file
9
9
### Added
10
10
11
11
- Arabic translations
12
+ - Ability to add a link to make table rows clickable
12
13
13
14
### Changed
14
15
Original file line number Diff line number Diff line change @@ -250,6 +250,11 @@ public function setTableRowId($model) : ?string;
250
250
*/
251
251
public function setTableRowAttributes($model) : array;
252
252
253
+ /**
254
+ * Return a URL to go to when the table row is clicked
255
+ */
256
+ public function getTableRowUrl($model): ?string;
257
+
253
258
/**
254
259
* Used to set the class of a table cell based on the column and the value of the cell
255
260
*/
Original file line number Diff line number Diff line change @@ -17,6 +17,10 @@ class="{{ $this->setTableRowClass($model) }}"
17
17
@foreach ($this -> setTableRowAttributes ($model ) as $key => $value )
18
18
{{ $key } } =" {{ $value } }"
19
19
@endforeach
20
+ @if ($this -> getTableRowUrl ($model ) )
21
+ onclick =" window.location='{{ $this -> getTableRowUrl ($model ) } } ';"
22
+ style =" cursor :pointer "
23
+ @endif
20
24
>
21
25
@if ($checkbox && $checkboxLocation === ' left' )
22
26
@include (' laravel-livewire-tables::includes._checkbox-row' )
Original file line number Diff line number Diff line change @@ -114,6 +114,16 @@ public function setTableRowAttributes($model): array
114
114
return [];
115
115
}
116
116
117
+ /**
118
+ * @param $model
119
+ *
120
+ * @return string|null
121
+ */
122
+ public function getTableRowUrl ($ model ): ?string
123
+ {
124
+ return null ;
125
+ }
126
+
117
127
/**
118
128
* @param $attribute
119
129
* @param $value
You can’t perform that action at this time.
0 commit comments