2017-08-16 03:21:47 +00:00
|
|
|
<?php
|
|
|
|
|
2017-10-07 04:57:53 +00:00
|
|
|
namespace Pterodactyl\Services\Nests;
|
2017-08-16 03:21:47 +00:00
|
|
|
|
2017-10-03 03:51:13 +00:00
|
|
|
use Ramsey\Uuid\Uuid;
|
2017-10-07 04:57:53 +00:00
|
|
|
use Pterodactyl\Models\Nest;
|
|
|
|
use Pterodactyl\Contracts\Repository\NestRepositoryInterface;
|
2017-08-16 03:21:47 +00:00
|
|
|
use Illuminate\Contracts\Config\Repository as ConfigRepository;
|
|
|
|
|
2017-10-07 04:57:53 +00:00
|
|
|
class NestCreationService
|
2017-08-16 03:21:47 +00:00
|
|
|
{
|
|
|
|
/**
|
2017-10-07 04:57:53 +00:00
|
|
|
* NestCreationService constructor.
|
2017-08-16 03:21:47 +00:00
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function __construct(private ConfigRepository $config, private NestRepositoryInterface $repository)
|
2017-10-08 04:29:08 +00:00
|
|
|
{
|
2017-08-16 03:21:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-10-07 04:57:53 +00:00
|
|
|
* Create a new nest on the system.
|
2017-08-16 03:21:47 +00:00
|
|
|
*
|
|
|
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
|
|
|
*/
|
2017-11-04 18:01:54 +00:00
|
|
|
public function handle(array $data, string $author = null): Nest
|
2017-08-16 03:21:47 +00:00
|
|
|
{
|
2017-10-03 03:51:13 +00:00
|
|
|
return $this->repository->create([
|
|
|
|
'uuid' => Uuid::uuid4()->toString(),
|
2017-11-04 18:01:54 +00:00
|
|
|
'author' => $author ?? $this->config->get('pterodactyl.service.author'),
|
2017-08-16 03:21:47 +00:00
|
|
|
'name' => array_get($data, 'name'),
|
|
|
|
'description' => array_get($data, 'description'),
|
2017-10-03 03:51:13 +00:00
|
|
|
], true, true);
|
2017-08-16 03:21:47 +00:00
|
|
|
}
|
|
|
|
}
|