1 | <?php namespace Arcanedev\Notify\Stores; |
||
13 | class SessionStore implements Store |
||
14 | { |
||
15 | /* ----------------------------------------------------------------- |
||
16 | | Properties |
||
17 | | ----------------------------------------------------------------- |
||
18 | */ |
||
19 | |||
20 | /** |
||
21 | * The Illuminate Session instance. |
||
22 | * |
||
23 | * @var \Illuminate\Contracts\Session\Session |
||
24 | */ |
||
25 | private $session; |
||
26 | |||
27 | /** |
||
28 | * The store's options. |
||
29 | * |
||
30 | * @var array |
||
31 | */ |
||
32 | protected $options; |
||
33 | |||
34 | /* ----------------------------------------------------------------- |
||
35 | | Constructor |
||
36 | | ----------------------------------------------------------------- |
||
37 | */ |
||
38 | |||
39 | /** |
||
40 | * Make session store instance. |
||
41 | * |
||
42 | * @param \Illuminate\Contracts\Session\Session $session |
||
43 | * @param array $options |
||
44 | */ |
||
45 | 48 | public function __construct(SessionContract $session, array $options) |
|
50 | |||
51 | /* ----------------------------------------------------------------- |
||
52 | | Getters |
||
53 | | ----------------------------------------------------------------- |
||
54 | */ |
||
55 | |||
56 | /** |
||
57 | * Get the session key. |
||
58 | * |
||
59 | * @return string |
||
60 | */ |
||
61 | 48 | protected function getSessionKey(): string |
|
65 | |||
66 | /* ----------------------------------------------------------------- |
||
67 | | Main Methods |
||
68 | | ----------------------------------------------------------------- |
||
69 | */ |
||
70 | |||
71 | /** |
||
72 | * Get all the notifications. |
||
73 | * |
||
74 | * @return \Illuminate\Support\Collection |
||
75 | */ |
||
76 | 48 | public function all(): Collection |
|
82 | |||
83 | /** |
||
84 | * Push the new notification. |
||
85 | * |
||
86 | * @param array $notification |
||
87 | */ |
||
88 | 40 | public function push(array $notification) |
|
95 | |||
96 | /** |
||
97 | * Forget the notifications. |
||
98 | * |
||
99 | * @return void |
||
100 | */ |
||
101 | 8 | public function forget() |
|
105 | |||
106 | /** |
||
107 | * Check if it has notifications. |
||
108 | * |
||
109 | * @return bool |
||
110 | */ |
||
111 | 40 | public function isEmpty(): bool |
|
115 | |||
116 | /** |
||
117 | * Check if there is no notifications. |
||
118 | * |
||
119 | * @return bool |
||
120 | */ |
||
121 | 40 | public function isNotEmpty(): bool |
|
125 | } |
||
126 |