@@ -20,8 +20,8 @@ public function mountWithPerPagePagination(): void
20
20
$ this ->perPageAccepted [] = -1 ;
21
21
}
22
22
23
- if (in_array (session ()->get ($ this ->tableName . ' -perPage ' , $ this ->perPage ), $ this ->perPageAccepted , true )) {
24
- $ this ->perPage = session ()->get ($ this ->tableName . ' -perPage ' , $ this ->perPage );
23
+ if (in_array (session ()->get ($ this ->getPerPagePaginationSessionKey () , $ this ->perPage ), $ this ->perPageAccepted , true )) {
24
+ $ this ->perPage = session ()->get ($ this ->getPerPagePaginationSessionKey () , $ this ->perPage );
25
25
} else {
26
26
$ this ->perPage = $ this ->perPageAccepted [0 ] ?? 10 ;
27
27
}
@@ -32,10 +32,10 @@ public function mountWithPerPagePagination(): void
32
32
*/
33
33
public function updatedPerPage ($ value ): void
34
34
{
35
- if (in_array (session ()->get ($ this ->tableName . ' -perPage ' , $ this ->perPage ), $ this ->perPageAccepted , true )) {
36
- session ()->put ($ this ->tableName . ' -perPage ' , (int ) $ value );
35
+ if (in_array (session ()->get ($ this ->getPerPagePaginationSessionKey () , $ this ->perPage ), $ this ->perPageAccepted , true )) {
36
+ session ()->put ($ this ->getPerPagePaginationSessionKey () , (int ) $ value );
37
37
} else {
38
- session ()->put ($ this ->tableName . ' -perPage ' , $ this ->perPageAccepted [0 ] ?? 10 );
38
+ session ()->put ($ this ->getPerPagePaginationSessionKey () , $ this ->perPageAccepted [0 ] ?? 10 );
39
39
}
40
40
41
41
$ this ->resetPage ();
@@ -49,4 +49,9 @@ public function applyPagination($query)
49
49
{
50
50
return $ query ->paginate ($ this ->perPage === -1 ? $ query ->count () : $ this ->perPage , ['* ' ], $ this ->pageName ());
51
51
}
52
+
53
+ private function getPerPagePaginationSessionKey (): string
54
+ {
55
+ return $ this ->tableName .'-perPage ' ;
56
+ }
52
57
}
0 commit comments