mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-11-04 02:16:54 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			25 lines
		
	
	
		
			568 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			568 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace App\Services\Nodes;
 | 
						|
 | 
						|
use Ramsey\Uuid\Uuid;
 | 
						|
use Illuminate\Support\Str;
 | 
						|
use App\Models\Node;
 | 
						|
 | 
						|
class NodeCreationService
 | 
						|
{
 | 
						|
    /**
 | 
						|
     * Create a new node on the panel.
 | 
						|
     *
 | 
						|
     * @throws \App\Exceptions\Model\DataValidationException
 | 
						|
     */
 | 
						|
    public function handle(array $data): Node
 | 
						|
    {
 | 
						|
        $data['uuid'] = Uuid::uuid4()->toString();
 | 
						|
        $data['daemon_token'] = Str::random(Node::DAEMON_TOKEN_LENGTH);
 | 
						|
        $data['daemon_token_id'] = Str::random(Node::DAEMON_TOKEN_ID_LENGTH);
 | 
						|
 | 
						|
        return Node::query()->create($data);
 | 
						|
    }
 | 
						|
}
 |