1 | <?php |
||
11 | class Config implements ArrayAccess, Countable |
||
12 | { |
||
13 | /** |
||
14 | * The config db key. |
||
15 | * |
||
16 | * @var string|null |
||
17 | */ |
||
18 | protected $configKey; |
||
19 | |||
20 | /** |
||
21 | * The config data. |
||
22 | * |
||
23 | * @var array |
||
24 | */ |
||
25 | protected $data; |
||
26 | |||
27 | /** |
||
28 | * The Model instance. |
||
29 | * |
||
30 | * @var \Illuminate\Database\Eloquent\Model |
||
31 | */ |
||
32 | protected $model; |
||
33 | |||
34 | /** |
||
35 | * Create a new Config instance. |
||
36 | * |
||
37 | * @param string $configKey |
||
38 | */ |
||
39 | public function __construct(Model $model, $configKey = null) |
||
47 | |||
48 | /** |
||
49 | * Get an attribute from config. |
||
50 | * |
||
51 | * @param string $key |
||
52 | * @param mixed $default |
||
53 | * @return mixed |
||
54 | */ |
||
55 | public function get(string $key, $default = null) |
||
59 | |||
60 | /** |
||
61 | * Determine if an attribute exists in config. |
||
62 | * |
||
63 | * @param string $key |
||
64 | * @return bool |
||
65 | */ |
||
66 | public function has(string $key) |
||
70 | |||
71 | /** |
||
72 | * Set an attribute in config. |
||
73 | * |
||
74 | * @param string $key |
||
75 | * @param bool $value |
||
76 | * @return bool|null |
||
77 | */ |
||
78 | public function set(string $key, $value) |
||
84 | |||
85 | /** |
||
86 | * Remove an attribute from config. |
||
87 | * |
||
88 | * @param string $key |
||
89 | * @return Config |
||
90 | */ |
||
91 | public function remove(string $key) |
||
97 | |||
98 | /** |
||
99 | * Get all attributes from config. |
||
100 | * |
||
101 | * @return array |
||
102 | */ |
||
103 | public function all() |
||
107 | |||
108 | /** |
||
109 | * Count attributes in config. |
||
110 | * |
||
111 | * @return int |
||
112 | */ |
||
113 | public function count() |
||
117 | |||
118 | /** |
||
119 | * Get a specific attribute as a collection. |
||
120 | * |
||
121 | * @param string $key |
||
122 | * @return \Illuminate\Support\Collection |
||
123 | */ |
||
124 | public function collect(string $key) |
||
128 | |||
129 | /** |
||
130 | * Get the config key. |
||
131 | * |
||
132 | * @return string |
||
133 | */ |
||
134 | protected function getConfigKey() |
||
138 | |||
139 | /** |
||
140 | * Get the raw data from the model. |
||
141 | * |
||
142 | * @return array |
||
143 | */ |
||
144 | protected function getRawData() |
||
148 | |||
149 | /** |
||
150 | * Determine if the given attribute exists. |
||
151 | * |
||
152 | * @param string $offset |
||
153 | * @return bool |
||
154 | */ |
||
155 | public function offsetExists($offset) |
||
159 | |||
160 | /** |
||
161 | * Get the value for a given offset. |
||
162 | * |
||
163 | * @param string $offset |
||
164 | * @return mixed |
||
165 | */ |
||
166 | public function offsetGet($offset) |
||
170 | |||
171 | /** |
||
172 | * Set the value for a given offset. |
||
173 | * |
||
174 | * @param string $offset |
||
175 | * @param mixed $value |
||
176 | * @return void |
||
177 | */ |
||
178 | public function offsetSet($offset, $value) |
||
182 | |||
183 | /** |
||
184 | * Unset the value for a given offset. |
||
185 | * |
||
186 | * @param string $offset |
||
187 | * @return void |
||
188 | */ |
||
189 | public function offsetUnset($offset) |
||
193 | |||
194 | /** |
||
195 | * Get an attribute from config. |
||
196 | * |
||
197 | * @param string $key |
||
198 | * @return mixed |
||
199 | */ |
||
200 | public function __get($key) |
||
204 | |||
205 | /** |
||
206 | * Determine if an attribute exists in config. |
||
207 | * |
||
208 | * @param string $key |
||
209 | * @return bool |
||
210 | */ |
||
211 | public function __isset($key) |
||
215 | |||
216 | /** |
||
217 | * Set an attribute in config. |
||
218 | * |
||
219 | * @param string $key |
||
220 | * @param bool $value |
||
221 | */ |
||
222 | public function __set($key, $value) |
||
226 | |||
227 | /** |
||
228 | * Remove an attribute from config. |
||
229 | * |
||
230 | * @param string $key |
||
231 | */ |
||
232 | public function __unset($key) |
||
236 | } |
||
237 |