1 | <?php namespace Arcanedev\Notify; |
||
14 | class Notify implements NotifyContract |
||
15 | { |
||
16 | /* ----------------------------------------------------------------- |
||
17 | | Traits |
||
18 | | ----------------------------------------------------------------- |
||
19 | */ |
||
20 | |||
21 | use Macroable; |
||
22 | |||
23 | /* ----------------------------------------------------------------- |
||
24 | | Properties |
||
25 | | ----------------------------------------------------------------- |
||
26 | */ |
||
27 | |||
28 | /** |
||
29 | * The session writer. |
||
30 | * |
||
31 | * @var \Arcanedev\Notify\Contracts\Store |
||
32 | */ |
||
33 | private $store; |
||
34 | |||
35 | /* ----------------------------------------------------------------- |
||
36 | | Constructor |
||
37 | | ----------------------------------------------------------------- |
||
38 | */ |
||
39 | |||
40 | /** |
||
41 | * Create a new flash notifier instance. |
||
42 | * |
||
43 | * @param \Arcanedev\Notify\Contracts\Store $store |
||
44 | */ |
||
45 | 48 | public function __construct(Store $store) |
|
49 | |||
50 | /* ----------------------------------------------------------------- |
||
51 | | Getters & Setters |
||
52 | | ----------------------------------------------------------------- |
||
53 | */ |
||
54 | |||
55 | /** |
||
56 | * Get the store. |
||
57 | * |
||
58 | * @return \Arcanedev\Notify\Contracts\Store |
||
59 | */ |
||
60 | 48 | public function store(): Store |
|
64 | |||
65 | /** |
||
66 | * Set the store. |
||
67 | * |
||
68 | * @param \Arcanedev\Notify\Contracts\Store $store |
||
69 | * |
||
70 | * @return $this |
||
71 | */ |
||
72 | 48 | public function setStore(Store $store) |
|
78 | |||
79 | /** |
||
80 | * Get all the notifications. |
||
81 | * |
||
82 | * @return \Illuminate\Support\Collection |
||
83 | */ |
||
84 | 40 | public function notifications(): Collection |
|
88 | |||
89 | /* ----------------------------------------------------------------- |
||
90 | | Main Methods |
||
91 | | ----------------------------------------------------------------- |
||
92 | */ |
||
93 | |||
94 | /** |
||
95 | * Flash an information message. |
||
96 | * |
||
97 | * @param string $message |
||
98 | * @param array $extra |
||
99 | * |
||
100 | * @return $this |
||
101 | */ |
||
102 | 8 | public function info(string $message, array $extra = []) |
|
106 | |||
107 | /** |
||
108 | * Flash a success message. |
||
109 | * |
||
110 | * @param string $message |
||
111 | * @param array $extra |
||
112 | * |
||
113 | * @return $this |
||
114 | */ |
||
115 | 8 | public function success(string $message, array $extra = []) |
|
119 | |||
120 | /** |
||
121 | * Flash an error message. |
||
122 | * |
||
123 | * @param string $message |
||
124 | * @param array $extra |
||
125 | * |
||
126 | * @return $this |
||
127 | */ |
||
128 | 8 | public function error(string $message, array $extra = []) |
|
132 | |||
133 | /** |
||
134 | * Flash a warning message. |
||
135 | * |
||
136 | * @param string $message |
||
137 | * @param array $extra |
||
138 | * |
||
139 | * @return $this |
||
140 | */ |
||
141 | 8 | public function warning(string $message, array $extra = []) |
|
145 | |||
146 | /** |
||
147 | * Flash a new notification. |
||
148 | * |
||
149 | * @param string $message |
||
150 | * @param string|null $type |
||
151 | * @param array $extra |
||
152 | * |
||
153 | * @return $this |
||
154 | */ |
||
155 | 40 | public function flash($message, $type = 'info', array $extra = []) |
|
161 | |||
162 | /** |
||
163 | * Forget the notification. |
||
164 | * |
||
165 | * @return void |
||
166 | */ |
||
167 | 8 | public function forget() |
|
171 | |||
172 | /** |
||
173 | * Check if it has notifications. |
||
174 | * |
||
175 | * @return bool |
||
176 | */ |
||
177 | 28 | public function isEmpty(): bool |
|
181 | |||
182 | /** |
||
183 | * Check if there is no notifications. |
||
184 | * |
||
185 | * @return bool |
||
186 | */ |
||
187 | 40 | public function isNotEmpty(): bool |
|
191 | } |
||
192 |