Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/database/Seeders/NestSeeder.php
7459 views
1
<?php
2
3
namespace Database\Seeders;
4
5
use Illuminate\Database\Seeder;
6
use Pterodactyl\Services\Nests\NestCreationService;
7
use Pterodactyl\Contracts\Repository\NestRepositoryInterface;
8
9
class NestSeeder extends Seeder
10
{
11
/**
12
* @var NestCreationService
13
*/
14
private $creationService;
15
16
/**
17
* @var NestRepositoryInterface
18
*/
19
private $repository;
20
21
/**
22
* NestSeeder constructor.
23
*/
24
public function __construct(
25
NestCreationService $creationService,
26
NestRepositoryInterface $repository,
27
) {
28
$this->creationService = $creationService;
29
$this->repository = $repository;
30
}
31
32
/**
33
* Run the seeder to add missing nests to the Panel.
34
*
35
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
36
*/
37
public function run()
38
{
39
$items = $this->repository->findWhere([
40
'author' => '[email protected]',
41
])->keyBy('name')->toArray();
42
43
$this->createMinecraftNest(array_get($items, 'Minecraft'));
44
$this->createSourceEngineNest(array_get($items, 'Source Engine'));
45
$this->createVoiceServersNest(array_get($items, 'Voice Servers'));
46
$this->createRustNest(array_get($items, 'Rust'));
47
}
48
49
/**
50
* Create the Minecraft nest to be used later on.
51
*
52
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
53
*/
54
private function createMinecraftNest(?array $nest = null)
55
{
56
if (is_null($nest)) {
57
$this->creationService->handle([
58
'name' => 'Minecraft',
59
'description' => 'Minecraft - the classic game from Mojang. With support for Vanilla MC, Spigot, and many others!',
60
], '[email protected]');
61
}
62
}
63
64
/**
65
* Create the Source Engine Games nest to be used later on.
66
*
67
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
68
*/
69
private function createSourceEngineNest(?array $nest = null)
70
{
71
if (is_null($nest)) {
72
$this->creationService->handle([
73
'name' => 'Source Engine',
74
'description' => 'Includes support for most Source Dedicated Server games.',
75
], '[email protected]');
76
}
77
}
78
79
/**
80
* Create the Voice Servers nest to be used later on.
81
*
82
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
83
*/
84
private function createVoiceServersNest(?array $nest = null)
85
{
86
if (is_null($nest)) {
87
$this->creationService->handle([
88
'name' => 'Voice Servers',
89
'description' => 'Voice servers such as Mumble and Teamspeak 3.',
90
], '[email protected]');
91
}
92
}
93
94
/**
95
* Create the Rust nest to be used later on.
96
*
97
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
98
*/
99
private function createRustNest(?array $nest = null)
100
{
101
if (is_null($nest)) {
102
$this->creationService->handle([
103
'name' => 'Rust',
104
'description' => 'Rust - A game where you must fight to survive.',
105
], '[email protected]');
106
}
107
}
108
}
109
110