-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathShowNotification.php
44 lines (38 loc) · 1018 Bytes
/
ShowNotification.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace App\Http\Livewire;
use Illuminate\Contracts\Foundation\Application as ApplicationContract;
use Illuminate\Contracts\View\Factory;
use Illuminate\Foundation\Application;
use Livewire\Component;
class ShowNotification extends Component
{
public $notification;
public $text;
/**
* Marks notification in the database as read
* @return void
*/
public function readNotification()
{
$this->notification->markAsRead();
$this->emitUp('refreshParentComponent');
}
/**
* Triggered when initializing the component
* @param $notification
* @return void
*/
public function mount($notification)
{
$this->notification = $notification;
$this->text = $notification->data['text'];
}
/**
* Render the component
* @return Factory|Application|\Illuminate\Contracts\View\View|ApplicationContract
*/
public function render()
{
return view('livewire.show-notification');
}
}