-
Notifications
You must be signed in to change notification settings - Fork 0
/
BoothObserver.php
55 lines (48 loc) · 1.19 KB
/
BoothObserver.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
48
49
50
51
52
53
54
55
<?php
namespace App\Observers;
use App\Models\Booth;
use App\Notifications\NotifyBoothApproved;
use App\Notifications\NotifyBoothDisapproved;
class BoothObserver
{
/**
* Handle the Booth "created" event.
*/
public function created(Booth $booth): void
{
//
}
/**
* Handle the Booth "updated" event.
*/
public function updated(Booth $booth): void
{
// use $booth->getChanges(), i.e. to check if 'is_approved` is changed,
// it should be a key in the returning associative array
if (array_key_exists('is_approved', $booth->getChanges())
&& $booth->is_approved) {
$booth->team->owner->notify(new NotifyBoothApproved($booth->team));
}
}
/**
* Handle the Booth "deleted" event.
*/
public function deleted(Booth $booth): void
{
$booth->team->owner->notify(new NotifyBoothDisapproved($booth->team));
}
/**
* Handle the Booth "restored" event.
*/
public function restored(Booth $booth): void
{
//
}
/**
* Handle the Booth "force deleted" event.
*/
public function forceDeleted(Booth $booth): void
{
//
}
}