File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change 2
2
3
3
namespace Rappasoft \LaravelLivewireTables \Traits ;
4
4
5
+ use Illuminate \Database \Eloquent \Builder ;
6
+
5
7
/**
6
8
* Trait WithBulkActions.
7
9
*/
@@ -41,7 +43,7 @@ public function updatedSelectPage($value): void
41
43
42
44
public function selectPageRows (): void
43
45
{
44
- $ this ->selected = $ this ->rows ->pluck ($ this ->primaryKey )->map (fn ($ id ) => (string ) $ id );
46
+ $ this ->selected = $ this ->rows ->pluck ($ this ->primaryKey )->map (fn ($ key ) => (string ) $ key );
45
47
}
46
48
47
49
public function selectAll (): void
@@ -56,14 +58,24 @@ public function resetBulk(): void
56
58
$ this ->selected = [];
57
59
}
58
60
59
- public function getSelectedRowsQueryProperty ()
61
+ public function selectedRowsQuery (): Builder
60
62
{
61
63
return (clone $ this ->rowsQuery ())
62
64
->unless ($ this ->selectAll , fn ($ query ) => $ query ->whereKey ($ this ->selected ));
63
65
}
64
66
65
- public function getSelectedKeysProperty ()
67
+ public function getSelectedRowsQueryProperty (): Builder
68
+ {
69
+ return $ this ->selectedRowsQuery ();
70
+ }
71
+
72
+ public function selectedKeys (): array
73
+ {
74
+ return $ this ->selectedRowsQuery ()->pluck ($ this ->primaryKey )->toArray ();
75
+ }
76
+
77
+ public function getSelectedKeysProperty (): array
66
78
{
67
- return $ this ->selectedRowsQuery -> pluck ( $ this -> primaryKey )-> toArray ();
79
+ return $ this ->selectedKeys ();
68
80
}
69
81
}
You can’t perform that action at this time.
0 commit comments