misc_pterodactyl-panel/app/Services/Nests/NestCreationService.php

36 lines
890 B
PHP
Raw Normal View History

<?php
namespace Pterodactyl\Services\Nests;
2017-10-02 22:51:13 -05:00
use Ramsey\Uuid\Uuid;
use Pterodactyl\Models\Nest;
use Illuminate\Contracts\Config\Repository as ConfigRepository;
class NestCreationService
{
/**
* NestCreationService constructor.
*/
2022-10-23 20:15:11 -04:00
public function __construct(private ConfigRepository $config)
2017-10-07 23:29:08 -05:00
{
}
/**
* Create a new nest on the system.
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
public function handle(array $data, string $author = null): Nest
{
2022-10-23 20:15:11 -04:00
/** @var Nest $nest */
$nest = Nest::query()->create([
2017-10-02 22:51:13 -05:00
'uuid' => Uuid::uuid4()->toString(),
'author' => $author ?? $this->config->get('pterodactyl.service.author'),
'name' => array_get($data, 'name'),
'description' => array_get($data, 'description'),
2022-10-23 20:15:11 -04:00
]);
return $nest;
}
}