From 48df84fb1981f83f0fcef1d5ce053595154c100d Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 3 May 2023 14:24:18 +0200 Subject: [PATCH] fix: private key change view --- app/Http/Livewire/PrivateKey/Change.php | 28 ++++++++++--------- .../livewire/private-key/change.blade.php | 6 ++-- resources/views/private-key/show.blade.php | 2 +- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/app/Http/Livewire/PrivateKey/Change.php b/app/Http/Livewire/PrivateKey/Change.php index bede7aca4..a070e600b 100644 --- a/app/Http/Livewire/PrivateKey/Change.php +++ b/app/Http/Livewire/PrivateKey/Change.php @@ -7,12 +7,18 @@ class Change extends Component { - public $private_keys; + public string $private_key_uuid; + public PrivateKey $private_key; - public $private_key_uuid; - public $private_key_value; - public $private_key_name; - public $private_key_description; + protected $rules = [ + 'private_key.name' => 'required|string', + 'private_key.description' => 'nullable|string', + 'private_key.private_key' => 'required|string' + ]; + public function mount() + { + $this->private_key = PrivateKey::where('uuid', $this->private_key_uuid)->first(); + } public function delete($private_key_uuid) { PrivateKey::where('uuid', $private_key_uuid)->delete(); @@ -22,15 +28,11 @@ public function delete($private_key_uuid) 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"; + $this->private_key->private_key = trim($this->private_key->private_key); + if (!str_ends_with($this->private_key->private_key, "\n")) { + $this->private_key->private_key .= "\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, - ]); + $this->private_key->save(); session('currentTeam')->privateKeys = PrivateKey::where('team_id', session('currentTeam')->id)->get(); } catch (\Exception $e) { $this->addError('private_key_value', $e->getMessage()); diff --git a/resources/views/livewire/private-key/change.blade.php b/resources/views/livewire/private-key/change.blade.php index fa2165b10..72585eb9d 100644 --- a/resources/views/livewire/private-key/change.blade.php +++ b/resources/views/livewire/private-key/change.blade.php @@ -1,8 +1,8 @@
- - - + + + Submit diff --git a/resources/views/private-key/show.blade.php b/resources/views/private-key/show.blade.php index 0e6c01de1..9d108ecf6 100644 --- a/resources/views/private-key/show.blade.php +++ b/resources/views/private-key/show.blade.php @@ -1,4 +1,4 @@

Private Key

- +