misc_pterodactyl-panel/database/Seeders/NestSeeder.php

102 lines
3 KiB
PHP
Raw Normal View History

2017-11-04 04:07:18 +00:00
<?php
namespace Database\Seeders;
2017-11-04 04:07:18 +00:00
use Illuminate\Database\Seeder;
2022-10-24 00:15:11 +00:00
use Pterodactyl\Models\Nest;
2017-11-04 04:07:18 +00:00
use Pterodactyl\Services\Nests\NestCreationService;
class NestSeeder extends Seeder
{
/**
* @var \Pterodactyl\Services\Nests\NestCreationService
*/
private $creationService;
/**
* NestSeeder constructor.
2017-11-04 04:07:18 +00:00
*/
2022-10-24 00:15:11 +00:00
public function __construct(NestCreationService $creationService)
{
2017-11-04 04:07:18 +00:00
$this->creationService = $creationService;
}
/**
* Run the seeder to add missing nests to the Panel.
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
public function run()
{
2022-10-24 00:15:11 +00:00
$items = Nest::query()
->where('author', 'support@pterodactyl.io')
->get()
->keyBy('name')->toArray();
2017-11-04 04:07:18 +00:00
$this->createMinecraftNest(array_get($items, 'Minecraft'));
$this->createSourceEngineNest(array_get($items, 'Source Engine'));
$this->createVoiceServersNest(array_get($items, 'Voice Servers'));
2017-11-06 02:24:58 +00:00
$this->createRustNest(array_get($items, 'Rust'));
2017-11-04 04:07:18 +00:00
}
/**
* Create the Minecraft nest to be used later on.
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
private function createMinecraftNest(array $nest = null)
{
if (is_null($nest)) {
$this->creationService->handle([
'name' => 'Minecraft',
'description' => 'Minecraft - the classic game from Mojang. With support for Vanilla MC, Spigot, and many others!',
], 'support@pterodactyl.io');
2017-11-04 04:07:18 +00:00
}
}
/**
* Create the Source Engine Games nest to be used later on.
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
private function createSourceEngineNest(array $nest = null)
{
if (is_null($nest)) {
$this->creationService->handle([
'name' => 'Source Engine',
'description' => 'Includes support for most Source Dedicated Server games.',
], 'support@pterodactyl.io');
2017-11-04 04:07:18 +00:00
}
}
/**
2017-11-06 02:24:58 +00:00
* Create the Voice Servers nest to be used later on.
2017-11-04 04:07:18 +00:00
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
private function createVoiceServersNest(array $nest = null)
{
if (is_null($nest)) {
$this->creationService->handle([
'name' => 'Voice Servers',
'description' => 'Voice servers such as Mumble and Teamspeak 3.',
], 'support@pterodactyl.io');
2017-11-04 04:07:18 +00:00
}
}
2017-11-06 02:24:58 +00:00
/**
* Create the Rust nest to be used later on.
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
private function createRustNest(array $nest = null)
{
if (is_null($nest)) {
$this->creationService->handle([
'name' => 'Rust',
'description' => 'Rust - A game where you must fight to survive.',
], 'support@pterodactyl.io');
}
}
2017-11-04 04:07:18 +00:00
}