File tree Expand file tree Collapse file tree 1 file changed +22
-6
lines changed
Expand file tree Collapse file tree 1 file changed +22
-6
lines changed Original file line number Diff line number Diff line change 22
33namespace Statamic \Listeners \Concerns ;
44
5+ use Illuminate \Support \LazyCollection ;
56use Statamic \Facades \Entry ;
67use Statamic \Facades \GlobalSet ;
78use Statamic \Facades \Term ;
@@ -12,14 +13,29 @@ trait GetsItemsContainingData
1213 /**
1314 * Get items containing data.
1415 *
15- * @return \Illuminate\Support\Collection
16+ * @return \Illuminate\Support\LazyCollection
1617 */
1718 public function getItemsContainingData ()
1819 {
19- return collect ()
20- ->merge (Entry::all ())
21- ->merge (Term::all ())
22- ->merge (GlobalSet::all ()->flatMap (fn ($ set ) => $ set ->localizations ()->values ()))
23- ->merge (User::all ());
20+ $ collections = [
21+ LazyCollection::make (function () {
22+ yield from Entry::query ()->lazy ();
23+ }),
24+ LazyCollection::make (function () {
25+ yield from Term::query ()->lazy ();
26+ }),
27+ LazyCollection::make (function () {
28+ yield from GlobalSet::all ()->flatMap (fn ($ set ) => $ set ->localizations ()->values ());
29+ }),
30+ LazyCollection::make (function () {
31+ yield from User::query ()->lazy ();
32+ }),
33+ ];
34+
35+ return LazyCollection::make (function () use ($ collections ) {
36+ foreach ($ collections as $ collection ) {
37+ yield from $ collection ;
38+ }
39+ });
2440 }
2541}
You can’t perform that action at this time.
0 commit comments