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