File manager - Edit - /var/www/payraty/helpdesk/common/Files/Traits/ChunksChildEntries.php
Back
<?php namespace Common\Files\Traits; use Common\Files\FileEntry; use Illuminate\Support\Collection; trait ChunksChildEntries { /** * Run callback over specified entries and all their children in chunks. */ protected function chunkChildEntries( array|Collection $entries, callable $callback, ): void { $entries = collect($entries); // if there are no folders, we can bail early $folders = $entries->filter(fn($entry) => $entry->type === 'folder'); if ($folders->isEmpty()) { $entries->chunk(400)->each($callback); } $builder = FileEntry::select(['id', 'file_name', 'type']) ->whereIn('id', $entries->pluck('id')) ->withTrashed(); $folders->each(function (FileEntry $entry) use ($builder) { $path = $entry->getRawOriginal('path'); $builder->orWhere('path', 'LIKE', "$path/%"); }); $builder->chunk(400, $callback); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.30 | Generation time: 0.84 |
proxy
|
phpinfo
|
Settings