Skip to content

Commit 1c5b9db

Browse files
committed
[L6] Update cursor() calls to work with new lazy collections
1 parent 08bdc97 commit 1c5b9db

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

app/Console/Commands/Server/BulkPowerActionCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function handle()
9898
$bar = $this->output->createProgressBar($count);
9999
$servers = $this->repository->getServersForPowerAction($servers, $nodes);
100100

101-
foreach ($servers as $server) {
101+
$servers->each(function ($server) use ($action, &$bar) {
102102
$bar->clear();
103103

104104
try {
@@ -117,7 +117,7 @@ public function handle()
117117

118118
$bar->advance();
119119
$bar->display();
120-
}
120+
});
121121

122122
$this->line('');
123123
}

app/Contracts/Repository/NodeRepositoryInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace Pterodactyl\Contracts\Repository;
44

5-
use Generator;
65
use Pterodactyl\Models\Node;
76
use Illuminate\Support\Collection;
7+
use Illuminate\Support\LazyCollection;
88
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
99
use Pterodactyl\Contracts\Repository\Attributes\SearchableInterface;
1010

@@ -69,7 +69,7 @@ public function getNodesForServerCreation(): Collection;
6969
* @param array $locations
7070
* @param int $disk
7171
* @param int $memory
72-
* @return \Generator
72+
* @return \Illuminate\Support\LazyCollection
7373
*/
74-
public function getNodesWithResourceUse(array $locations, int $disk, int $memory): Generator;
74+
public function getNodesWithResourceUse(array $locations, int $disk, int $memory): LazyCollection;
7575
}

app/Contracts/Repository/ServerRepositoryInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function getByUuid(string $uuid): Server;
133133
* @param int[] $servers
134134
* @param int[] $nodes
135135
* @param bool $returnCount
136-
* @return int|\Generator
136+
* @return int|\Illuminate\Support\LazyCollection
137137
*/
138138
public function getServersForPowerAction(array $servers = [], array $nodes = [], bool $returnCount = false);
139139

app/Repositories/Eloquent/NodeRepository.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace Pterodactyl\Repositories\Eloquent;
44

5-
use Generator;
65
use Pterodactyl\Models\Node;
76
use Illuminate\Support\Collection;
7+
use Illuminate\Support\LazyCollection;
88
use Pterodactyl\Repositories\Concerns\Searchable;
99
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
1010
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
@@ -172,9 +172,9 @@ public function getNodesForServerCreation(): Collection
172172
* @param array $locations
173173
* @param int $disk
174174
* @param int $memory
175-
* @return \Generator
175+
* @return \Illuminate\Support\LazyCollection
176176
*/
177-
public function getNodesWithResourceUse(array $locations, int $disk, int $memory): Generator
177+
public function getNodesWithResourceUse(array $locations, int $disk, int $memory): LazyCollection
178178
{
179179
$instance = $this->getBuilder()
180180
->select(['nodes.id', 'nodes.memory', 'nodes.disk', 'nodes.memory_overallocate', 'nodes.disk_overallocate'])

app/Repositories/Eloquent/ServerRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ public function getByUuid(string $uuid): Server
291291
* @param int[] $servers
292292
* @param int[] $nodes
293293
* @param bool $returnCount
294-
* @return int|\Generator
294+
* @return int|\Illuminate\Support\LazyCollection
295295
*/
296296
public function getServersForPowerAction(array $servers = [], array $nodes = [], bool $returnCount = false)
297297
{

0 commit comments

Comments
 (0)