Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions src/Listeners/Concerns/GetsItemsContainingData.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Statamic\Listeners\Concerns;

use Illuminate\Support\LazyCollection;
use Statamic\Facades\Entry;
use Statamic\Facades\GlobalSet;
use Statamic\Facades\Term;
Expand All @@ -12,14 +13,29 @@ trait GetsItemsContainingData
/**
* Get items containing data.
*
* @return \Illuminate\Support\Collection
* @return \Illuminate\Support\LazyCollection
*/
public function getItemsContainingData()
{
return collect()
->merge(Entry::all())
->merge(Term::all())
->merge(GlobalSet::all()->flatMap(fn ($set) => $set->localizations()->values()))
->merge(User::all());
$collections = [
LazyCollection::make(function () {
yield from Entry::query()->lazy();
}),
LazyCollection::make(function () {
yield from Term::query()->lazy();
}),
LazyCollection::make(function () {
yield from GlobalSet::all()->flatMap(fn ($set) => $set->localizations()->values());
}),
LazyCollection::make(function () {
yield from User::query()->lazy();
}),
];

return LazyCollection::make(function () use ($collections) {
foreach ($collections as $collection) {
yield from $collection;
}
});
}
}