Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions app/Http/Livewire/Notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Http\Livewire;

use App\Policies\NotificationPolicy;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Notifications\DatabaseNotification;
use Illuminate\Support\Facades\Auth;
Expand Down Expand Up @@ -34,18 +33,14 @@ public function getNotificationProperty(): DatabaseNotification
return DatabaseNotification::findOrFail($this->notificationId);
}

public function markAsRead(string $notificationId): LengthAwarePaginator
public function markAsRead(string $notificationId): void
{
$this->notificationId = $notificationId;

$this->authorize(NotificationPolicy::MARK_AS_READ, $this->notification);

$this->notification->markAsRead();

$unreadNotifications = Auth::user()->unreadNotifications()->paginate(10);

$this->emit('NotificationMarkedAsRead', $unreadNotifications->total());

return $unreadNotifications;
$this->emit('NotificationMarkedAsRead', Auth::user()->unreadNotifications()->count());
}
}