File tree Expand file tree Collapse file tree 3 files changed +54
-0
lines changed Expand file tree Collapse file tree 3 files changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
4
4
The format is based on [ Keep a Changelog] ( http://keepachangelog.com/en/1.0.0/ )
5
5
and this project adheres to [ Semantic Versioning] ( http://semver.org/spec/v2.0.0.html ) .
6
6
7
+ ## [ 0.2.61] - 31 May 2018
8
+ ### Fixed
9
+ - caching of paginated queries with page identifiers as arrays (` ?page[size]=1 ` ).
10
+
11
+ ## [ 0.2.60] - 27 May 2018
12
+ ### Added
13
+ - unit tests for multiple versions of Laravel simultaneously.
14
+ - backwards-compatibility to Laravel 5.4.
15
+
7
16
## [ 0.2.59] - 27 May 2018
8
17
### Fixed
9
18
- caching of queries with ` whereNotIn ` clauses.
Original file line number Diff line number Diff line change @@ -127,11 +127,34 @@ public function paginate(
127
127
}
128
128
129
129
$ page = request ("page " , $ page ?: 1 );
130
+
131
+ if (is_array ($ page )) {
132
+ $ page = $ this ->recursiveImplodeWithKey ($ page );
133
+ }
134
+ dump ($ perPage , $ columns , $ pageName , $ page );
135
+
130
136
$ cacheKey = $ this ->makeCacheKey ($ columns , null , "-paginate_by_ {$ perPage }_ {$ pageName }_ {$ page }" );
131
137
132
138
return $ this ->cachedValue (func_get_args (), $ cacheKey );
133
139
}
134
140
141
+ protected function recursiveImplodeWithKey (array $ items , string $ glue = "_ " ) : string
142
+ {
143
+ $ result = "" ;
144
+
145
+ foreach ($ items as $ key => $ value ) {
146
+ if (is_array ($ value )) {
147
+ $ result .= $ key . $ glue . $ this ->recursiveImplode ($ value , $ glue );
148
+
149
+ continue ;
150
+ }
151
+
152
+ $ result .= $ glue . $ key . $ glue . $ value ;
153
+ }
154
+
155
+ return $ result ;
156
+ }
157
+
135
158
public function pluck ($ column , $ key = null )
136
159
{
137
160
if (! $ this ->isCachable ()) {
Original file line number Diff line number Diff line change @@ -33,4 +33,26 @@ public function testPaginationProvidesDifferentLinksOnDifferentPages()
33
33
$ page2 ->see ($ page2ActiveLink );
34
34
$ page2 ->see ($ book ->title );
35
35
}
36
+
37
+ public function testAdvancedPagination ()
38
+ {
39
+ if (starts_with (app ()->version (), "5.6 " )) {
40
+ $ page1ActiveLink = '<li class="page-item active" aria-current="page"><span class="page-link">1</span></li> ' ;
41
+ $ page2ActiveLink = '<li class="page-item active" aria-current="page"><span class="page-link">2</span></li> ' ;
42
+ }
43
+
44
+ if (starts_with (app ()->version (), "5.5 " )) {
45
+ $ page1ActiveLink = '<li class="active"><span>1</span></li> ' ;
46
+ $ page2ActiveLink = '<li class="active"><span>2</span></li> ' ;
47
+ }
48
+
49
+ if (starts_with (app ()->version (), "5.4 " )) {
50
+ $ page1ActiveLink = '<li class="active"><span>1</span></li> ' ;
51
+ $ page2ActiveLink = '<li class="active"><span>2</span></li> ' ;
52
+ }
53
+
54
+ $ response = $ this ->visit ("pagination-test?page[size]=1 " );
55
+
56
+ $ response ->see ($ page1ActiveLink );
57
+ }
36
58
}
You can’t perform that action at this time.
0 commit comments