lasthourcloud/app/Http/Livewire/PrivateKey/Create.php
Andras Bacsai fd89735521 Added +add flows everywhere
ui: changed vibrant button to not so vibrant
2023-07-26 13:23:47 +02:00

45 lines
1.3 KiB
PHP

<?php
namespace App\Http\Livewire\PrivateKey;
use App\Models\PrivateKey;
use Livewire\Component;
class Create extends Component
{
public string|null $from = null;
public string $name;
public string|null $description = null;
public string $value;
protected $rules = [
'name' => 'required|string',
'value' => 'required|string',
];
protected $validationAttributes = [
'name' => 'name',
'value' => 'private Key',
];
public function createPrivateKey()
{
$this->validate();
try {
$this->value = trim($this->value);
if (!str_ends_with($this->value, "\n")) {
$this->value .= "\n";
}
$private_key = PrivateKey::create([
'name' => $this->name,
'description' => $this->description,
'private_key' => $this->value,
'team_id' => session('currentTeam')->id
]);
if ($this->from === 'server') {
return redirect()->route('server.create');
}
return redirect()->route('private-key.show', ['private_key_uuid' => $private_key->uuid]);
} catch (\Exception $e) {
return general_error_handler(err: $e, that: $this);
}
}
}