Replace node repository

This commit is contained in:
Lance Pioch 2022-10-23 22:17:24 -04:00
parent 7266c66ebf
commit aeb7590a6d
14 changed files with 101 additions and 250 deletions

View file

@ -6,21 +6,19 @@ use Ramsey\Uuid\Uuid;
use Illuminate\Support\Str;
use Pterodactyl\Models\Node;
use Illuminate\Contracts\Encryption\Encrypter;
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
class NodeCreationService
{
/**
* NodeCreationService constructor.
*/
public function __construct(private Encrypter $encrypter, protected NodeRepositoryInterface $repository)
public function __construct(private Encrypter $encrypter)
{
}
/**
* Create a new node on the panel.
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
public function handle(array $data): Node
{
@ -28,6 +26,9 @@ class NodeCreationService
$data['daemon_token'] = $this->encrypter->encrypt(Str::random(Node::DAEMON_TOKEN_LENGTH));
$data['daemon_token_id'] = Str::random(Node::DAEMON_TOKEN_ID_LENGTH);
return $this->repository->create($data, true, true);
/** @var Node $node */
$node = Node::query()->create($data);
return $node;
}
}