Path: blob/1.0-develop/database/Seeders/NestSeeder.php
7459 views
<?php12namespace Database\Seeders;34use Illuminate\Database\Seeder;5use Pterodactyl\Services\Nests\NestCreationService;6use Pterodactyl\Contracts\Repository\NestRepositoryInterface;78class NestSeeder extends Seeder9{10/**11* @var NestCreationService12*/13private $creationService;1415/**16* @var NestRepositoryInterface17*/18private $repository;1920/**21* NestSeeder constructor.22*/23public function __construct(24NestCreationService $creationService,25NestRepositoryInterface $repository,26) {27$this->creationService = $creationService;28$this->repository = $repository;29}3031/**32* Run the seeder to add missing nests to the Panel.33*34* @throws \Pterodactyl\Exceptions\Model\DataValidationException35*/36public function run()37{38$items = $this->repository->findWhere([39'author' => '[email protected]',40])->keyBy('name')->toArray();4142$this->createMinecraftNest(array_get($items, 'Minecraft'));43$this->createSourceEngineNest(array_get($items, 'Source Engine'));44$this->createVoiceServersNest(array_get($items, 'Voice Servers'));45$this->createRustNest(array_get($items, 'Rust'));46}4748/**49* Create the Minecraft nest to be used later on.50*51* @throws \Pterodactyl\Exceptions\Model\DataValidationException52*/53private function createMinecraftNest(?array $nest = null)54{55if (is_null($nest)) {56$this->creationService->handle([57'name' => 'Minecraft',58'description' => 'Minecraft - the classic game from Mojang. With support for Vanilla MC, Spigot, and many others!',59], '[email protected]');60}61}6263/**64* Create the Source Engine Games nest to be used later on.65*66* @throws \Pterodactyl\Exceptions\Model\DataValidationException67*/68private function createSourceEngineNest(?array $nest = null)69{70if (is_null($nest)) {71$this->creationService->handle([72'name' => 'Source Engine',73'description' => 'Includes support for most Source Dedicated Server games.',74], '[email protected]');75}76}7778/**79* Create the Voice Servers nest to be used later on.80*81* @throws \Pterodactyl\Exceptions\Model\DataValidationException82*/83private function createVoiceServersNest(?array $nest = null)84{85if (is_null($nest)) {86$this->creationService->handle([87'name' => 'Voice Servers',88'description' => 'Voice servers such as Mumble and Teamspeak 3.',89], '[email protected]');90}91}9293/**94* Create the Rust nest to be used later on.95*96* @throws \Pterodactyl\Exceptions\Model\DataValidationException97*/98private function createRustNest(?array $nest = null)99{100if (is_null($nest)) {101$this->creationService->handle([102'name' => 'Rust',103'description' => 'Rust - A game where you must fight to survive.',104], '[email protected]');105}106}107}108109110