Skip to content

Commit

Permalink
feat: added logout & delete account
Browse files Browse the repository at this point in the history
  • Loading branch information
stevan06v committed Oct 1, 2024
1 parent ebbf853 commit 79ea5de
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use App\Models\User;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ public function save()
try {
$this->validate();
$monitor = Monitor::whereId($this->monitor_id)->first();
dd($this->monitor_id);
$monitor->pat_token = $this->pat_token;
$monitor->save();
$this->pat_token_edit_success_message = "Successfully updated the PAT-TOKEN.";
} catch (Exception $e) {
Expand All @@ -46,7 +46,7 @@ public function save()
<br>
<select id="customSelect" wire:model="monitor_id" class="block appearance-none w-full bg-white p-3 rounded-md border-other-grey border-2 text-gray-700">
@foreach($monitors as $iterator)
<option value="{{ $iterator['id'] }}">{{ $iterator['organization_name'] }}</option>
<option value="{{ $iterator->id }}">{{ $iterator->organization_name }}</option>
@endforeach
</select>

Expand Down
28 changes: 28 additions & 0 deletions resources/views/livewire/settings/profile/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
use App\Models\User;
use Livewire\Attributes\Validate;
use Illuminate\Support\Facades\Auth;
use Livewire\Volt\Component;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Hash;
new class extends Component {
Expand Down Expand Up @@ -34,6 +36,27 @@ public function save()
$this->account_edit_error_message = $e->getMessage();
$this->error_head = "Seems like something went wrong...";
}
}
public function delte_account()
{
try{
$user = User::whereId(Auth::user()->id)->first();
$user->monitors()->delete();
$user->delete();
Auth::logout();
return Redirect::to('login');
}catch (Exception $e){
$this->account_edit_error_message = $e->getMessage();
$this->error_head = "Seems like something went wrong...";
}
}
public function logout()
{
Auth::logout();
return Redirect::to('login');
}
}; ?>

Expand All @@ -51,6 +74,11 @@ public function save()
<sl-button wire:ignore type="submit" wire:loading.attr="disabled" wire:ignore>Save</sl-button>
</form>

<div class="flex justify-end gap-2 p-3.5">
<button wire:click="logout" class="text-white text-sm font-bold border-primary-blue bg-primary-blue border-2 rounded-md p-2">LOGOUT</button>
<button wire:click="delte_account" class="text-white text-sm font-bold border-additional-red bg-additional-red border-2 rounded-md p-2">DELTE</button>
</div>

@if($account_edit_error_message)
<sl-alert variant="danger" open closable>
<sl-icon wire:ignore slot="icon" name="patch-exclamation"></sl-icon>
Expand Down

0 comments on commit 79ea5de

Please sign in to comment.