Skip to content

Commit 87ad15b

Browse files
feat:[lar-139] transfert notification page to livewire page
1 parent feae698 commit 87ad15b

File tree

10 files changed

+45
-11
lines changed

10 files changed

+45
-11
lines changed

app/Livewire/NotificationCount.php renamed to app/Livewire/Pages/Notifications/Count.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
declare(strict_types=1);
44

5-
namespace App\Livewire;
5+
namespace App\Livewire\Pages\Notifications;
66

77
use Illuminate\Contracts\View\View;
88
use Illuminate\Support\Facades\Auth;
99
use Livewire\Component;
1010

11-
final class NotificationCount extends Component
11+
final class Count extends Component
1212
{
1313
public int $count = 0;
1414

@@ -28,7 +28,7 @@ public function render(): View
2828
{
2929
$this->count = Auth::user()->unreadNotifications()->count(); // @phpstan-ignore-line
3030

31-
return view('livewire.notification-count', [
31+
return view('livewire.pages.notifications.count', [
3232
'count' => $this->count,
3333
]);
3434
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Livewire\Pages\Notifications;
6+
7+
use Illuminate\Contracts\View\View;
8+
use Livewire\Component;
9+
10+
final class Index extends Component
11+
{
12+
public function render(): View
13+
{
14+
return view('livewire.pages.notifications.index');
15+
}
16+
}

app/Livewire/NotificationIndicator.php renamed to app/Livewire/Pages/Notifications/Indicator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
declare(strict_types=1);
44

5-
namespace App\Livewire;
5+
namespace App\Livewire\Pages\Notifications;
66

77
use Illuminate\Contracts\View\View;
88
use Illuminate\Support\Facades\Auth;
99
use Livewire\Attributes\On;
1010
use Livewire\Component;
1111

12-
final class NotificationIndicator extends Component
12+
final class Indicator extends Component
1313
{
1414
public bool $hasNotification = false;
1515

@@ -25,7 +25,7 @@ public function render(): View
2525
Auth::user()->unreadNotifications()->count(), // @phpstan-ignore-line
2626
);
2727

28-
return view('livewire.notification-indicator', [
28+
return view('livewire.pages.notifications.indicator', [
2929
'hasNotification' => $this->hasNotification,
3030
]);
3131
}

app/Livewire/NotificationsPage.php renamed to app/Livewire/Pages/Notifications/Page.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace App\Livewire;
5+
namespace App\Livewire\Pages\Notifications;
66

77
use App\Policies\NotificationPolicy;
88
use Carbon\Carbon;
@@ -13,7 +13,7 @@
1313
use Illuminate\Support\Facades\Auth;
1414
use Livewire\Component;
1515

16-
final class NotificationsPage extends Component
16+
final class Page extends Component
1717
{
1818
use AuthorizesRequests;
1919

@@ -48,7 +48,7 @@ public function markAsRead(string $notificationId): void
4848

4949
public function render(): View
5050
{
51-
return view('livewire.notifications-page', [
51+
return view('livewire.pages.notifications.page', [
5252
// @phpstan-ignore-next-line
5353
'notifications' => Auth::user()
5454
->unreadNotifications()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<x-slot:title>
3232
<span class="sr-only">{{ __('global.view_notifications') }}</span>
3333
<x-untitledui-bell class="size-5" aria-hidden="true" />
34-
<livewire:notification-indicator />
34+
<livewire:pages.notifications.indicator />
3535
</x-slot:title>
3636
</x-nav.item>
3737

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<div>
2+
<x-container class="py-12">
3+
<div>
4+
<x-user.breadcrumb section="Notifications" />
5+
6+
<h2
7+
class="inline-flex items-center gap-x-2 font-heading text-xl font-bold leading-7 text-gray-900 dark:text-white sm:truncate sm:text-2xl"
8+
>
9+
{{ __('Notifications') }}
10+
<livewire:pages.notifications.count />
11+
</h2>
12+
</div>
13+
14+
<section class="relative mt-8">
15+
<livewire:pages.notifications.page />
16+
</section>
17+
</x-container>
18+
</div>

routes/web.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
Route::get('subscribeable/{id}/{type}', [SubscriptionController::class, 'redirect'])->name('subscriptions.redirect');
4545

4646
// Notifications
47-
Route::view('notifications', 'user.notifications')
47+
Route::get('notifications', App\Livewire\Pages\Notifications\Index::class)
4848
->name('notifications')
4949
->middleware(['auth', 'checkIfBanned']);
5050

0 commit comments

Comments
 (0)