coolify/app/Http/Livewire/PrivateKey/Create.php

35 lines
865 B
PHP
Raw Normal View History

2023-05-03 12:38:57 +02:00
<?php
namespace App\Http\Livewire\PrivateKey;
use App\Models\PrivateKey;
2023-05-04 09:11:11 +02:00
use Illuminate\Support\Facades\Route;
2023-05-03 12:38:57 +02:00
use Livewire\Component;
class Create extends Component
{
2023-05-12 15:39:07 +02:00
public string $name;
2023-05-15 14:54:03 +02:00
public string|null $description = null;
2023-05-12 15:39:07 +02:00
public string $value;
2023-05-04 09:11:11 +02:00
public string $currentRoute;
public function mount()
{
$this->currentRoute = Route::current()->uri();
}
2023-05-03 12:38:57 +02:00
public function createPrivateKey()
{
2023-05-12 15:39:07 +02:00
$this->value = trim($this->value);
if (!str_ends_with($this->value, "\n")) {
$this->value .= "\n";
2023-05-03 12:38:57 +02:00
}
2023-05-03 14:09:10 +02:00
$new_private_key = PrivateKey::create([
2023-05-12 15:39:07 +02:00
'name' => $this->name,
'description' => $this->description,
'private_key' => $this->value,
2023-05-03 12:38:57 +02:00
'team_id' => session('currentTeam')->id
]);
2023-05-15 14:54:03 +02:00
redirect()->route('server.new');
2023-05-03 12:38:57 +02:00
}
}