25 lines
574 B
PHP
25 lines
574 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\View\Composers;
|
|
|
|
use App\Models\UserNotification;
|
|
use Illuminate\View\View;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class NavigationComposer
|
|
{
|
|
public function compose(View $view): void
|
|
{
|
|
if (Auth::check()) {
|
|
$view->with('unreadNotifications', UserNotification::where('user_id', Auth::id())
|
|
->where('is_read', false)
|
|
->orderByDesc('created_at')
|
|
->get());
|
|
} else {
|
|
$view->with('unreadNotifications', collect());
|
|
}
|
|
}
|
|
}
|