|
1
|
|
|
<?php |
|
2
|
|
|
namespace Fenos\Notifynder\Builder; |
|
3
|
|
|
|
|
4
|
|
|
use JsonSerializable; |
|
5
|
|
|
use Illuminate\Contracts\Support\Arrayable; |
|
6
|
|
|
use Illuminate\Contracts\Support\Jsonable; |
|
7
|
|
|
use Illuminate\Support\Arr; |
|
8
|
|
|
|
|
9
|
|
|
class Notification implements Arrayable, Jsonable, JsonSerializable |
|
10
|
|
|
{ |
|
11
|
|
|
protected $attributes = []; |
|
12
|
|
|
|
|
13
|
|
|
public function attributes() |
|
14
|
|
|
{ |
|
15
|
|
|
return $this->attributes; |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
public function attribute($key, $default = null) |
|
19
|
|
|
{ |
|
20
|
|
|
return $this->get($key, $default); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
public function get($key, $default = null) |
|
24
|
|
|
{ |
|
25
|
|
|
return Arr::get($this->attributes, $key, $default); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function set($key, $value) |
|
29
|
|
|
{ |
|
30
|
|
|
Arr::set($this->attributes, $key, $value); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
public function __get($key) |
|
34
|
|
|
{ |
|
35
|
|
|
return $this->get($key); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public function __set($key, $value) |
|
39
|
|
|
{ |
|
40
|
|
|
$this->set($key, $value); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function toJson($options = 0) |
|
44
|
|
|
{ |
|
45
|
|
|
return json_encode($this->jsonSerialize(), $options); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function jsonSerialize() |
|
49
|
|
|
{ |
|
50
|
|
|
return $this->toArray(); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function toArray() |
|
54
|
|
|
{ |
|
55
|
|
|
return array_map(function ($value) { |
|
56
|
|
|
return $value instanceof Arrayable ? $value->toArray() : $value; |
|
57
|
|
|
}, $this->attributes); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function __toString() |
|
61
|
|
|
{ |
|
62
|
|
|
return $this->toJson(); |
|
63
|
|
|
} |
|
64
|
|
|
} |