1 | <?php |
||
17 | class Notify implements NotifyContract |
||
18 | { |
||
19 | /* ----------------------------------------------------------------- |
||
20 | | Traits |
||
21 | | ----------------------------------------------------------------- |
||
22 | */ |
||
23 | |||
24 | 1 | use Macroable; |
|
25 | |||
26 | /* ----------------------------------------------------------------- |
||
27 | | Properties |
||
28 | | ----------------------------------------------------------------- |
||
29 | */ |
||
30 | |||
31 | /** |
||
32 | * The session writer. |
||
33 | * |
||
34 | * @var \Arcanedev\Notify\Contracts\Store |
||
35 | */ |
||
36 | private $store; |
||
37 | |||
38 | /* ----------------------------------------------------------------- |
||
39 | | Constructor |
||
40 | | ----------------------------------------------------------------- |
||
41 | */ |
||
42 | |||
43 | /** |
||
44 | * Create a new flash notifier instance. |
||
45 | * |
||
46 | * @param \Arcanedev\Notify\Contracts\Store $store |
||
47 | */ |
||
48 | 52 | public function __construct(StoreContract $store) |
|
52 | |||
53 | /* ----------------------------------------------------------------- |
||
54 | | Getters & Setters |
||
55 | | ----------------------------------------------------------------- |
||
56 | */ |
||
57 | |||
58 | /** |
||
59 | * Get the store. |
||
60 | * |
||
61 | * @return \Arcanedev\Notify\Contracts\Store |
||
62 | */ |
||
63 | 52 | public function store(): StoreContract |
|
67 | |||
68 | /** |
||
69 | * Set the store. |
||
70 | * |
||
71 | * @param \Arcanedev\Notify\Contracts\Store $store |
||
72 | * |
||
73 | * @return $this |
||
74 | */ |
||
75 | 52 | public function setStore(StoreContract $store) |
|
81 | |||
82 | /** |
||
83 | * Get all the notifications. |
||
84 | * |
||
85 | * @return \Illuminate\Support\Collection |
||
86 | */ |
||
87 | 40 | public function notifications(): Collection |
|
91 | |||
92 | /* ----------------------------------------------------------------- |
||
93 | | Main Methods |
||
94 | | ----------------------------------------------------------------- |
||
95 | */ |
||
96 | |||
97 | /** |
||
98 | * Flash an information message. |
||
99 | * |
||
100 | * @param string $message |
||
101 | * @param array $extra |
||
102 | * |
||
103 | * @return $this |
||
104 | */ |
||
105 | 8 | public function info(string $message, array $extra = []) |
|
109 | |||
110 | /** |
||
111 | * Flash a success message. |
||
112 | * |
||
113 | * @param string $message |
||
114 | * @param array $extra |
||
115 | * |
||
116 | * @return $this |
||
117 | */ |
||
118 | 8 | public function success(string $message, array $extra = []) |
|
122 | |||
123 | /** |
||
124 | * Flash an error message. |
||
125 | * |
||
126 | * @param string $message |
||
127 | * @param array $extra |
||
128 | * |
||
129 | * @return $this |
||
130 | */ |
||
131 | 8 | public function error(string $message, array $extra = []) |
|
135 | |||
136 | /** |
||
137 | * Flash a warning message. |
||
138 | * |
||
139 | * @param string $message |
||
140 | * @param array $extra |
||
141 | * |
||
142 | * @return $this |
||
143 | */ |
||
144 | 8 | public function warning(string $message, array $extra = []) |
|
148 | |||
149 | /** |
||
150 | * Flash a new notification. |
||
151 | * |
||
152 | * @param string $message |
||
153 | * @param string|null $type |
||
154 | * @param array $extra |
||
155 | * |
||
156 | * @return $this |
||
157 | */ |
||
158 | 40 | public function flash($message, $type = 'info', array $extra = []) |
|
164 | |||
165 | /** |
||
166 | * Forget the notification. |
||
167 | */ |
||
168 | 8 | public function forget(): void |
|
172 | |||
173 | /** |
||
174 | * Check if it has notifications. |
||
175 | * |
||
176 | * @return bool |
||
177 | */ |
||
178 | 32 | public function isEmpty(): bool |
|
182 | |||
183 | /** |
||
184 | * Check if there is no notifications. |
||
185 | * |
||
186 | * @return bool |
||
187 | */ |
||
188 | 44 | public function isNotEmpty(): bool |
|
192 | } |
||
193 |