Test Failed
Push — master ( 7405ac...f937f1 )
by Burak
05:02
created

NotificationListener::mount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
3
namespace App\Http\Livewire;
4
5
use Livewire\Component;
6
7
class NotificationListener extends Component
8
{
9
    public bool $showNewNotificationBadge = false;
10
11
    public int $count = 88;
12
13
    public $user;
14
15
    // Computed Property
16
    public function getCountProperty()
17
    {
18
        dump('getCountProperty()');
19
        return 999; //$this->user->unreadNotifications()->count();
20
    }
21
22
    public function mount($user)
23
    {
24
        dump('mount:$user');
25
        $this->user = $user;
26
    }
27
28
    public function getListeners()
29
    {
30
        return [ // @todo {$this->user->id}
31
            "echo-private:App.Models.User.3dd6a60f-8c5d-49f8-b723-514ba4a941d6,BroadcastNotificationCreated" => 'showNewNotificationBadge',
32
        ];
33
    }
34
35
    public function showNewNotificationBadge()
36
    {
37
        dump('showNewNotificationBadge()');
38
        $this->showNewNotificationBadge = true;
39
        $this->count = 999; //$this->user->unreadNotifications()->count();
40
    }
41
42
    public function render()
43
    {
44
        return view('livewire.notification-listener');
45
    }
46
}
47