Skip to content

Commit 7583c82

Browse files
committed
fix: Volt components
1 parent b96b811 commit 7583c82

File tree

5 files changed

+57
-28
lines changed

5 files changed

+57
-28
lines changed

app/Livewire/Actions/Logout.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Livewire\Actions;
6+
7+
use Illuminate\Support\Facades\Auth;
8+
use Illuminate\Support\Facades\Session;
9+
10+
final class Logout
11+
{
12+
public function __invoke(): void
13+
{
14+
Auth::guard('web')->logout();
15+
16+
Session::invalidate();
17+
Session::regenerateToken();
18+
}
19+
}

config/app.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@
177177
App\Providers\AuthServiceProvider::class,
178178
// App\Providers\BroadcastServiceProvider::class,
179179
App\Providers\EventServiceProvider::class,
180+
App\Providers\VoltServiceProvider::class,
180181
App\Providers\RouteServiceProvider::class,
181182

182183
],

resources/views/components/dropdown-profile.blade.php

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -205,22 +205,8 @@ class="size-5 text-gray-400 dark:gray-500 group-hover:text-gray-500 dark:group-h
205205
/>
206206
{{ __('global.navigation.settings') }}
207207
</x-link>
208-
<form method="POST" action="{{ route('logout') }}">
209-
@csrf
210-
<button
211-
type="submit"
212-
class="group flex w-full items-center gap-2 py-1.5 text-sm text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-white"
213-
tabindex="-1"
214-
id="logout"
215-
>
216-
<x-icon.logout
217-
class="size-5 text-gray-400 dark:gray-500 group-hover:text-gray-500 dark:group-hover:text-gray-300"
218-
stroke-width="1.5"
219-
aria-hidden="true"
220-
/>
221-
{{ __('global.logout') }}
222-
</button>
223-
</form>
208+
209+
<livewire:components.logout />
224210
</div>
225211
</div>
226212
</div>

resources/views/components/layouts/header.blade.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,18 +116,7 @@ class="size-8"
116116
:href="route('user.settings')"
117117
:title="__('Paramètres')"
118118
/>
119-
<form method="POST" action="{{ route('logout') }}">
120-
@csrf
121-
<button
122-
type="submit"
123-
class="group flex w-full items-center text-sm font-medium text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-white"
124-
role="menuitem"
125-
tabindex="-1"
126-
id="logout-mobile"
127-
>
128-
{{ __('global.logout') }}
129-
</button>
130-
</form>
119+
<livewire:components.logout />
131120
</div>
132121
@else
133122
<div class="flex flex-col space-y-4">
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use App\Livewire\Actions\Logout;
6+
use Livewire\Volt\Component;
7+
8+
new class extends Component
9+
{
10+
/**
11+
* Log the current user out of the application.
12+
*/
13+
public function logout(Logout $logout): void
14+
{
15+
$logout();
16+
17+
$this->redirect('/', navigate: true);
18+
}
19+
}; ?>
20+
21+
<div>
22+
<button
23+
wire:click="logout"
24+
class="group flex w-full items-center gap-2 text-sm font-medium text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-white"
25+
tabindex="-1"
26+
>
27+
<x-icon.logout
28+
class="hidden size-5 text-gray-400 dark:gray-500 group-hover:text-gray-500 dark:group-hover:text-gray-300 lg:block"
29+
stroke-width="1.5"
30+
aria-hidden="true"
31+
/>
32+
{{ __('global.logout') }}
33+
</button>
34+
</div>

0 commit comments

Comments
 (0)