<?php

declare(strict_types=1);

namespace App\Http\View\Composers;

use Illuminate\Contracts\View\View;
use Illuminate\Database\Eloquent\Collection;

/**
 * Class UserNotificationComposer
 */
class UserNotificationComposer
{
    protected ?Collection $notifications;

    /**
     * UserNotificationComposer constructor.
     */
    public function __construct()
    {
        $this->notifications = auth()->user()->unreadNotifications;
    }

    public function compose(View $view): View
    {
        return $view->withUserNotifications($this->notifications);
    }
}
