|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Fenos\Notifynder\Collections; |
|
4
|
|
|
|
|
5
|
|
|
use Fenos\Notifynder\Contracts\ConfigContract; |
|
6
|
|
|
use Fenos\Notifynder\Models\Notification; |
|
7
|
|
|
use Illuminate\Support\Arr; |
|
8
|
|
|
|
|
9
|
|
|
class Config implements ConfigContract |
|
10
|
|
|
{ |
|
11
|
|
|
protected $items; |
|
12
|
|
|
|
|
13
|
|
|
public function __construct() |
|
14
|
|
|
{ |
|
15
|
|
|
$this->items = app('config')->get('notifynder'); |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
public function isPolymorphic() |
|
19
|
|
|
{ |
|
20
|
|
|
return (bool) $this->get('polymorphic'); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
public function getNotificationModel() |
|
24
|
|
|
{ |
|
25
|
|
|
$class = $this->get('notification_model'); |
|
26
|
|
|
if(class_exists($class)) { |
|
27
|
|
|
return $class; |
|
28
|
|
|
} |
|
29
|
|
|
return Notification::class; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function getNotifiedModel() |
|
33
|
|
|
{ |
|
34
|
|
|
$class = $this->get('model'); |
|
35
|
|
|
if(class_exists($class)) { |
|
36
|
|
|
return $class; |
|
37
|
|
|
} |
|
38
|
|
|
throw new \InvalidArgumentException("The model class [{$class}] doesn't exist."); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function getAdditionalFields() |
|
42
|
|
|
{ |
|
43
|
|
|
return Arr::flatten($this->get('additional_fields', [])); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function get($key, $default = null) |
|
47
|
|
|
{ |
|
48
|
|
|
return Arr::get($this->items, $key, $default); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function has($key) |
|
52
|
|
|
{ |
|
53
|
|
|
return Arr::has($this->items, $key); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function set($key, $value = null) |
|
57
|
|
|
{ |
|
58
|
|
|
Arr::set($this->items, $key, $value); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function __get($key) |
|
62
|
|
|
{ |
|
63
|
|
|
return $this->get($key); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function __set($key, $value) |
|
67
|
|
|
{ |
|
68
|
|
|
$this->set($key, $value); |
|
69
|
|
|
} |
|
70
|
|
|
} |