Path: blob/1.0-develop/app/Services/Nodes/NodeCreationService.php
10262 views
<?php12namespace Pterodactyl\Services\Nodes;34use Ramsey\Uuid\Uuid;5use Illuminate\Support\Str;6use Pterodactyl\Models\Node;7use Illuminate\Contracts\Encryption\Encrypter;8use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;910class NodeCreationService11{12/**13* NodeCreationService constructor.14*/15public function __construct(protected NodeRepositoryInterface $repository)16{17}1819/**20* Create a new node on the panel.21*22* @throws \Pterodactyl\Exceptions\Model\DataValidationException23*/24public function handle(array $data): Node25{26$data['uuid'] = Uuid::uuid4()->toString();27$data['daemon_token'] = app(Encrypter::class)->encrypt(Str::random(Node::DAEMON_TOKEN_LENGTH));28$data['daemon_token_id'] = Str::random(Node::DAEMON_TOKEN_ID_LENGTH);2930return $this->repository->create($data, true, true);31}32}333435