InAppNotificationsViewComposer::compose()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 2
eloc 6
nc 2
nop 1
1
<?php
2
3
namespace Hechoenlaravel\JarvisFoundation\Notifications\ViewComposers;
4
5
use Auth;
6
use Hechoenlaravel\JarvisFoundation\Notifications\SendAppNotification\Notification;
7
use Illuminate\Contracts\View\View;
8
9
class InAppNotificationsViewComposer
10
{
11
    /**
12
     * Bind data to the view.
13
     *
14
     * @param  View  $view
15
     * @return void
16
     */
17
    public function compose(View $view)
18
    {
19
        if (!Auth::guest()) {
20
            $n = Notification::byUser(Auth::user())->unread()->get();
21
            $view->with('notifications', [
22
                'count' => $n->count(),
23
                'notifications' => $n
24
            ]);
25
        }
26
    }
27
}
28