change/modify/delete/add private keys
This commit is contained in:
39
app/Http/Livewire/PrivateKey/Change.php
Normal file
39
app/Http/Livewire/PrivateKey/Change.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\PrivateKey;
|
||||
|
||||
use App\Models\PrivateKey;
|
||||
use Livewire\Component;
|
||||
|
||||
class Change extends Component
|
||||
{
|
||||
public $private_keys;
|
||||
|
||||
public $private_key_uuid;
|
||||
public $private_key_value;
|
||||
public $private_key_name;
|
||||
public $private_key_description;
|
||||
public function delete($private_key_uuid)
|
||||
{
|
||||
PrivateKey::where('uuid', $private_key_uuid)->delete();
|
||||
session('currentTeam')->privateKeys = PrivateKey::where('team_id', session('currentTeam')->id)->get();
|
||||
redirect()->route('dashboard');
|
||||
}
|
||||
public function changePrivateKey()
|
||||
{
|
||||
try {
|
||||
$this->private_key_value = trim($this->private_key_value);
|
||||
if (!str_ends_with($this->private_key_value, "\n")) {
|
||||
$this->private_key_value .= "\n";
|
||||
}
|
||||
PrivateKey::where('uuid', $this->private_key_uuid)->update([
|
||||
'name' => $this->private_key_name,
|
||||
'description' => $this->private_key_description,
|
||||
'private_key' => $this->private_key_value,
|
||||
]);
|
||||
session('currentTeam')->privateKeys = PrivateKey::where('team_id', session('currentTeam')->id)->get();
|
||||
} catch (\Exception $e) {
|
||||
$this->addError('private_key_value', $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
27
app/Http/Livewire/PrivateKey/Create.php
Normal file
27
app/Http/Livewire/PrivateKey/Create.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\PrivateKey;
|
||||
|
||||
use App\Models\PrivateKey;
|
||||
use Livewire\Component;
|
||||
|
||||
class Create extends Component
|
||||
{
|
||||
public $private_key_value;
|
||||
public $private_key_name;
|
||||
public $private_key_description;
|
||||
public function createPrivateKey()
|
||||
{
|
||||
$this->private_key_value = trim($this->private_key_value);
|
||||
if (!str_ends_with($this->private_key_value, "\n")) {
|
||||
$this->private_key_value .= "\n";
|
||||
}
|
||||
PrivateKey::create([
|
||||
'name' => $this->private_key_name,
|
||||
'description' => $this->private_key_description,
|
||||
'private_key' => $this->private_key_value,
|
||||
'team_id' => session('currentTeam')->id
|
||||
]);
|
||||
session('currentTeam')->privateKeys = PrivateKey::where('team_id', session('currentTeam')->id)->get();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user