-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathNotificationHandler.php
47 lines (41 loc) · 1015 Bytes
/
NotificationHandler.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
45
46
47
<?php
namespace App;
trait NotificationHandler
{
/**
* Boot the trait.
*/
protected static function bootNotificationHandler()
{
if (auth()->guest()) {
return;
}
// For future use
foreach (static::getActivitiesToRecord() as $event) {
static::$event(function ($model) use ($event) {
$model->recordActivity($event);
});
}
// On delete any records, delete its notification
static::deleting(function ($model) {
$model->notifications()->delete();
});
}
/**
* @return mixed
*/
public function notifications()
{
return $this->hasMany(\App\Notification::class, 'data->id')
->whereIn('type', self::$notifications);
}
/**
* Fetch all model events that require activity recording.
*
* @return array
*/
protected static function getActivitiesToRecord()
{
return [];
}
}