From 1c5b9dbb875f7265122c6092e99a13bc4e9d0d08 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Wed, 4 Sep 2019 21:05:46 -0700 Subject: [PATCH] [L6] Update cursor() calls to work with new lazy collections --- app/Console/Commands/Server/BulkPowerActionCommand.php | 4 ++-- app/Contracts/Repository/NodeRepositoryInterface.php | 6 +++--- app/Contracts/Repository/ServerRepositoryInterface.php | 2 +- app/Repositories/Eloquent/NodeRepository.php | 6 +++--- app/Repositories/Eloquent/ServerRepository.php | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/Console/Commands/Server/BulkPowerActionCommand.php b/app/Console/Commands/Server/BulkPowerActionCommand.php index c6b5e435f..f6aa798b6 100644 --- a/app/Console/Commands/Server/BulkPowerActionCommand.php +++ b/app/Console/Commands/Server/BulkPowerActionCommand.php @@ -98,7 +98,7 @@ class BulkPowerActionCommand extends Command $bar = $this->output->createProgressBar($count); $servers = $this->repository->getServersForPowerAction($servers, $nodes); - foreach ($servers as $server) { + $servers->each(function ($server) use ($action, &$bar) { $bar->clear(); try { @@ -117,7 +117,7 @@ class BulkPowerActionCommand extends Command $bar->advance(); $bar->display(); - } + }); $this->line(''); } diff --git a/app/Contracts/Repository/NodeRepositoryInterface.php b/app/Contracts/Repository/NodeRepositoryInterface.php index aef04e2a9..c1bb25c40 100644 --- a/app/Contracts/Repository/NodeRepositoryInterface.php +++ b/app/Contracts/Repository/NodeRepositoryInterface.php @@ -2,9 +2,9 @@ namespace Pterodactyl\Contracts\Repository; -use Generator; use Pterodactyl\Models\Node; use Illuminate\Support\Collection; +use Illuminate\Support\LazyCollection; use Illuminate\Contracts\Pagination\LengthAwarePaginator; use Pterodactyl\Contracts\Repository\Attributes\SearchableInterface; @@ -69,7 +69,7 @@ interface NodeRepositoryInterface extends RepositoryInterface, SearchableInterfa * @param array $locations * @param int $disk * @param int $memory - * @return \Generator + * @return \Illuminate\Support\LazyCollection */ - public function getNodesWithResourceUse(array $locations, int $disk, int $memory): Generator; + public function getNodesWithResourceUse(array $locations, int $disk, int $memory): LazyCollection; } diff --git a/app/Contracts/Repository/ServerRepositoryInterface.php b/app/Contracts/Repository/ServerRepositoryInterface.php index 6b758c3df..b82e84fa1 100644 --- a/app/Contracts/Repository/ServerRepositoryInterface.php +++ b/app/Contracts/Repository/ServerRepositoryInterface.php @@ -133,7 +133,7 @@ interface ServerRepositoryInterface extends RepositoryInterface, SearchableInter * @param int[] $servers * @param int[] $nodes * @param bool $returnCount - * @return int|\Generator + * @return int|\Illuminate\Support\LazyCollection */ public function getServersForPowerAction(array $servers = [], array $nodes = [], bool $returnCount = false); diff --git a/app/Repositories/Eloquent/NodeRepository.php b/app/Repositories/Eloquent/NodeRepository.php index 3b86f2ee1..8343129d5 100644 --- a/app/Repositories/Eloquent/NodeRepository.php +++ b/app/Repositories/Eloquent/NodeRepository.php @@ -2,9 +2,9 @@ namespace Pterodactyl\Repositories\Eloquent; -use Generator; use Pterodactyl\Models\Node; use Illuminate\Support\Collection; +use Illuminate\Support\LazyCollection; use Pterodactyl\Repositories\Concerns\Searchable; use Illuminate\Contracts\Pagination\LengthAwarePaginator; use Pterodactyl\Contracts\Repository\NodeRepositoryInterface; @@ -172,9 +172,9 @@ class NodeRepository extends EloquentRepository implements NodeRepositoryInterfa * @param array $locations * @param int $disk * @param int $memory - * @return \Generator + * @return \Illuminate\Support\LazyCollection */ - public function getNodesWithResourceUse(array $locations, int $disk, int $memory): Generator + public function getNodesWithResourceUse(array $locations, int $disk, int $memory): LazyCollection { $instance = $this->getBuilder() ->select(['nodes.id', 'nodes.memory', 'nodes.disk', 'nodes.memory_overallocate', 'nodes.disk_overallocate']) diff --git a/app/Repositories/Eloquent/ServerRepository.php b/app/Repositories/Eloquent/ServerRepository.php index f806c0f98..5b2fa8828 100644 --- a/app/Repositories/Eloquent/ServerRepository.php +++ b/app/Repositories/Eloquent/ServerRepository.php @@ -291,7 +291,7 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt * @param int[] $servers * @param int[] $nodes * @param bool $returnCount - * @return int|\Generator + * @return int|\Illuminate\Support\LazyCollection */ public function getServersForPowerAction(array $servers = [], array $nodes = [], bool $returnCount = false) {