File tree Expand file tree Collapse file tree 4 files changed +59
-1
lines changed
resources/views/model-caching-tests Expand file tree Collapse file tree 4 files changed +59
-1
lines changed Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ public function paginate(
115
115
return parent ::paginate ($ perPage , $ columns , $ pageName , $ page );
116
116
}
117
117
118
- $ page = $ page ?: 1 ;
118
+ $ page = request ( " page " , $ page ?: 1 ) ;
119
119
$ cacheKey = $ this ->makeCacheKey ($ columns , null , "-paginate_by_ {$ perPage }_ {$ pageName }_ {$ page }" );
120
120
121
121
return $ this ->cachedValue (func_get_args (), $ cacheKey );
Original file line number Diff line number Diff line change
1
+ <?php namespace GeneaLabs \LaravelModelCaching \Tests \Browser ;
2
+
3
+ use GeneaLabs \LaravelModelCaching \Tests \FeatureTestCase ;
4
+ use GeneaLabs \LaravelModelCaching \Tests \Fixtures \Book ;
5
+
6
+ class PaginationTest extends FeatureTestCase
7
+ {
8
+ public function testPaginationProvidesDifferentLinksOnDifferentPages ()
9
+ {
10
+ $ book = (new Book )
11
+ ->take (11 )
12
+ ->get ()
13
+ ->last ();
14
+ $ page1 = $ this ->visit ("pagination-test " );
15
+
16
+ $ this ->assertTrue (str_contains ($ page1 ->response ->getContent (), '<li class="page-item active"><span class="page-link">1</span></li> ' ));
17
+
18
+ $ page2 = $ page1 ->click ("2 " );
19
+
20
+ $ this ->assertTrue (str_contains ($ page2 ->response ->getContent (), '<li class="page-item active"><span class="page-link">2</span></li> ' ));
21
+ $ page2 ->see ($ book ->title );
22
+ }
23
+ }
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ <html >
3
+ <body >
4
+ <table >
5
+
6
+ @foreach ($books as $book )
7
+ <tr >
8
+ <td >
9
+ {{ $book -> id } }
10
+ </td >
11
+ <td >
12
+ {{ $book -> title } }
13
+ </td >
14
+ </tr >
15
+ @endforeach
16
+
17
+ </table >
18
+
19
+ {{ $books -> links () } }
20
+
21
+ </body >
22
+ </html >
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use GeneaLabs \LaravelModelCaching \Tests \Fixtures \Book ;
4
+
5
+ Route::get ('pagination-test ' , function () {
6
+ $ books = (new Book )
7
+ ->paginate (10 );
8
+
9
+ return view ("model-caching-tests.pagination " )
10
+ ->with (compact (
11
+ 'books '
12
+ ));
13
+ });
You can’t perform that action at this time.
0 commit comments