You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Depending on our coding style, we can initialize Lazy JSON Pages in 3 different ways:
57
+
Depending on our coding style, we can initialize Lazy JSON Pages in 4 different ways:
55
58
56
59
```php
57
60
use Cerbero\LazyJsonPages\LazyJsonPages;
61
+
use Illuminate\Support\LazyCollection;
58
62
59
63
use function Cerbero\LazyJsonPages\lazyJsonPages;
60
64
65
+
// lazy collection macro
66
+
LazyCollection::fromJsonPages($source);
67
+
61
68
// classic instantiation
62
-
$lazyJsonPages = new LazyJsonPages($source);
69
+
new LazyJsonPages($source);
63
70
64
-
// static method (easier methods chaining)
65
-
$lazyJsonPages = LazyJsonPages::from($source);
71
+
// static method
72
+
LazyJsonPages::from($source);
66
73
67
74
// namespaced helper
68
-
$lazyJsonPages = lazyJsonPages($source);
75
+
lazyJsonPages($source);
69
76
```
70
77
71
78
The variable `$source` in our examples represents any [source](#-sources) that points to a paginated JSON API. Once we define the source, we can then chain methods to define how the API is paginated:
0 commit comments