Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/app/Services/Nests/NestCreationService.php
10262 views
1
<?php
2
3
namespace Pterodactyl\Services\Nests;
4
5
use Ramsey\Uuid\Uuid;
6
use Pterodactyl\Models\Nest;
7
use Pterodactyl\Contracts\Repository\NestRepositoryInterface;
8
use Illuminate\Contracts\Config\Repository as ConfigRepository;
9
10
class NestCreationService
11
{
12
/**
13
* NestCreationService constructor.
14
*/
15
public function __construct(private ConfigRepository $config, private NestRepositoryInterface $repository)
16
{
17
}
18
19
/**
20
* Create a new nest on the system.
21
*
22
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
23
*/
24
public function handle(array $data, ?string $author = null): Nest
25
{
26
return $this->repository->create([
27
'uuid' => Uuid::uuid4()->toString(),
28
'author' => $author ?? $this->config->get('pterodactyl.service.author'),
29
'name' => array_get($data, 'name'),
30
'description' => array_get($data, 'description'),
31
], true, true);
32
}
33
}
34
35