1 | <?php |
||
16 | class Builder implements ArrayAccess |
||
17 | { |
||
18 | /** |
||
19 | * @var Notification |
||
20 | */ |
||
21 | protected $notification; |
||
22 | |||
23 | /** |
||
24 | * @var array |
||
25 | */ |
||
26 | protected $notifications = []; |
||
27 | |||
28 | /** |
||
29 | * Builder constructor. |
||
30 | */ |
||
31 | public function __construct() |
||
35 | |||
36 | /** |
||
37 | * Set the category for this notification. |
||
38 | * |
||
39 | * @param string|int|\Fenos\Notifynder\Models\NotificationCategory $category |
||
40 | * @return $this |
||
41 | */ |
||
42 | public function category($category) |
||
49 | |||
50 | /** |
||
51 | * Set the sender for this notification. |
||
52 | * |
||
53 | * @return $this |
||
54 | */ |
||
55 | public function from() |
||
62 | |||
63 | /** |
||
64 | * Set the sender anonymous for this notification. |
||
65 | * |
||
66 | * @return $this |
||
67 | */ |
||
68 | public function anonymous() |
||
75 | |||
76 | /** |
||
77 | * Set the receiver for this notification. |
||
78 | * |
||
79 | * @return $this |
||
80 | */ |
||
81 | public function to() |
||
88 | |||
89 | /** |
||
90 | * Set the url for this notification. |
||
91 | * |
||
92 | * @param string $url |
||
93 | * @return $this |
||
94 | */ |
||
95 | public function url($url) |
||
102 | |||
103 | /** |
||
104 | * Set the expire date for this notification. |
||
105 | * |
||
106 | * @param Carbon|\DateTime $datetime |
||
107 | * @return $this |
||
108 | */ |
||
109 | public function expire(Carbon $datetime) |
||
117 | |||
118 | /** |
||
119 | * Set the extra values for this notification. |
||
120 | * You can extend the existing extras or override them - important for multiple calls of extra() on one notification. |
||
121 | * |
||
122 | * @param array $extra |
||
123 | * @param bool $override |
||
124 | * @return $this |
||
125 | */ |
||
126 | public function extra(array $extra = [], $override = true) |
||
136 | |||
137 | /** |
||
138 | * Set updated_at and created_at fields. |
||
139 | */ |
||
140 | public function setDates() |
||
147 | |||
148 | /** |
||
149 | * Set a single field value. |
||
150 | * |
||
151 | * @param string $key |
||
152 | * @param mixed $value |
||
153 | * @return $this |
||
154 | */ |
||
155 | public function setField($key, $value) |
||
164 | |||
165 | /** |
||
166 | * Set polymorphic model values. |
||
167 | * |
||
168 | * @param array $entity |
||
169 | * @param string $property |
||
170 | */ |
||
171 | protected function setEntityData($entity, $property) |
||
192 | |||
193 | /** |
||
194 | * Get a single value of this notification. |
||
195 | * |
||
196 | * @param string $key |
||
197 | * @param null|mixed $default |
||
198 | * @return mixed |
||
199 | */ |
||
200 | protected function getNotificationData($key, $default = null) |
||
204 | |||
205 | /** |
||
206 | * Set a single value of this notification. |
||
207 | * |
||
208 | * @param string $key |
||
209 | * @param mixed $value |
||
210 | */ |
||
211 | protected function setNotificationData($key, $value) |
||
215 | |||
216 | /** |
||
217 | * Get the current notification. |
||
218 | * |
||
219 | * @return Notification |
||
220 | * @throws UnvalidNotificationException |
||
221 | */ |
||
222 | public function getNotification() |
||
232 | |||
233 | /** |
||
234 | * Add a notification to the notifications array. |
||
235 | * |
||
236 | * @param Notification $notification |
||
237 | */ |
||
238 | public function addNotification(Notification $notification) |
||
242 | |||
243 | /** |
||
244 | * Get all notifications. |
||
245 | * |
||
246 | * @return array |
||
247 | * @throws UnvalidNotificationException |
||
248 | */ |
||
249 | public function getNotifications() |
||
257 | |||
258 | /** |
||
259 | * Loop over data and call the callback with a new Builder instance and the key and value of the iterated data. |
||
260 | * |
||
261 | * @param array|\Traversable $data |
||
262 | * @param Closure $callback |
||
263 | * @return $this |
||
264 | * @throws UnvalidNotificationException |
||
265 | */ |
||
266 | public function loop($data, Closure $callback) |
||
278 | |||
279 | /** |
||
280 | * @param string $offset |
||
281 | * @return bool |
||
282 | */ |
||
283 | public function offsetExists($offset) |
||
287 | |||
288 | /** |
||
289 | * @param string $offset |
||
290 | * @return mixed |
||
291 | */ |
||
292 | public function offsetGet($offset) |
||
296 | |||
297 | /** |
||
298 | * @param string $offset |
||
299 | * @param mixed $value |
||
300 | */ |
||
301 | public function offsetSet($offset, $value) |
||
305 | |||
306 | /** |
||
307 | * @param string $offset |
||
308 | */ |
||
309 | public function offsetUnset($offset) |
||
313 | } |
||
314 |