Files
panel/app/Services/Nodes/NodeCreationService.php

25 lines
577 B
PHP
Raw Normal View History

<?php
2024-03-12 22:39:16 -04:00
namespace App\Services\Nodes;
use Ramsey\Uuid\Uuid;
use Illuminate\Support\Str;
2024-03-12 22:39:16 -04:00
use App\Models\Node;
class NodeCreationService
{
/**
* Create a new node on the panel.
*
2024-03-12 22:39:16 -04:00
* @throws \App\Exceptions\Model\DataValidationException
*/
public function handle(array $data): Node
{
$data['uuid'] = Uuid::uuid4()->toString();
2024-03-19 05:11:41 -04:00
$data['daemon_token'] = encrypt(Str::random(Node::DAEMON_TOKEN_LENGTH));
$data['daemon_token_id'] = Str::random(Node::DAEMON_TOKEN_ID_LENGTH);
2024-03-16 21:34:09 -04:00
return Node::query()->create($data);
}
}