33 * Here is helper functions
44 */
55
6- function array_diff_assoc_recursive ($ array1 , $ array2 ) {
7- $ difference =array ();
8- foreach ($ array1 as $ key => $ value ) {
9- if ( is_array ($ value ) ) {
10- if ( !isset ($ array2 [$ key ]) || !is_array ($ array2 [$ key ]) ) {
6+ function array_diff_assoc_recursive ($ array1 , $ array2 )
7+ {
8+ $ difference = array ();
9+ foreach ($ array1 as $ key => $ value ) {
10+ if (is_array ($ value )) {
11+ if (!isset ($ array2 [$ key ]) || !is_array ($ array2 [$ key ])) {
1112 $ difference [$ key ] = $ value ;
1213 } else {
1314 $ new_diff = array_diff_assoc_recursive ($ value , $ array2 [$ key ]);
14- if ( !empty ($ new_diff ) )
15+ if ( !empty ($ new_diff ))
1516 $ difference [$ key ] = $ new_diff ;
1617 }
17- } else if ( !array_key_exists ($ key ,$ array2 ) || $ array2 [$ key ] != $ value ) {
18+ } else if ( !array_key_exists ($ key , $ array2 ) || $ array2 [$ key ] != $ value ) {
1819 $ difference [$ key ] = $ value ;
1920 }
2021 }
2122 return $ difference ;
2223}
2324
24- if ( !function_exists ('str_finish ' )){
25+ if (!function_exists ('str_finish ' )) {
2526
2627 function str_finish ($ value , $ cap )
2728 {
2829 return \Illuminate \Support \Str::finish ($ value , $ cap );
2930 }
3031
32+ }
33+
34+ function paginate ($ items , $ perPage = 15 , $ page = null , $ options = [])
35+ {
36+ $ page = $ page ?: (\Illuminate \Pagination \Paginator::resolveCurrentPage () ?: 1 );
37+ $ items = $ items instanceof \Illuminate \Support \Collection ? $ items : \Illuminate \Support \Collection::make ($ items );
38+
39+ return new \Illuminate \Pagination \LengthAwarePaginator ($ items ->forPage ($ page , $ perPage ), $ items ->count (), $ perPage , $ page , $ options );
3140}
0 commit comments