1 | <?php namespace Arcanesoft\Settings\Stores; |
||
12 | class EloquentStore |
||
13 | { |
||
14 | /* ------------------------------------------------------------------------------------------------ |
||
15 | | Properties |
||
16 | | ------------------------------------------------------------------------------------------------ |
||
17 | */ |
||
18 | /** |
||
19 | * The Setting Eloquent Model. |
||
20 | * |
||
21 | * @var \Arcanesoft\Settings\Models\Setting |
||
22 | */ |
||
23 | protected $model; |
||
24 | |||
25 | /* ------------------------------------------------------------------------------------------------ |
||
26 | | Constructor |
||
27 | | ------------------------------------------------------------------------------------------------ |
||
28 | */ |
||
29 | /** |
||
30 | * SettingsManager constructor. |
||
31 | * |
||
32 | * @param \Arcanesoft\Settings\Models\Setting $model |
||
33 | * @param \Illuminate\Contracts\Cache\Repository $cache |
||
34 | */ |
||
35 | 40 | public function __construct(Setting $model, Cache $cache) |
|
40 | |||
41 | /* ------------------------------------------------------------------------------------------------ |
||
42 | | Getters & Setters |
||
43 | | ------------------------------------------------------------------------------------------------ |
||
44 | */ |
||
45 | /** |
||
46 | * Get the cache key. |
||
47 | * |
||
48 | * @return string |
||
49 | */ |
||
50 | 40 | protected function getCacheKey() |
|
54 | |||
55 | /** |
||
56 | * Check if cache is enabled. |
||
57 | * |
||
58 | * @return bool |
||
59 | */ |
||
60 | 40 | protected function isCached() |
|
64 | |||
65 | /** |
||
66 | * Get the config value by key. |
||
67 | * |
||
68 | * @param string $key |
||
69 | * @param mixed $default |
||
70 | * |
||
71 | * @return mixed |
||
72 | */ |
||
73 | 40 | private function config($key, $default = null) |
|
77 | |||
78 | /* ------------------------------------------------------------------------------------------------ |
||
79 | | Main Functions |
||
80 | | ------------------------------------------------------------------------------------------------ |
||
81 | */ |
||
82 | 40 | public function all() |
|
90 | |||
91 | 28 | public function save($saved, $changes) |
|
101 | |||
102 | /* ------------------------------------------------------------------------------------------------ |
||
103 | | Other Functions |
||
104 | | ------------------------------------------------------------------------------------------------ |
||
105 | */ |
||
106 | /** |
||
107 | * Save the inserted entries. |
||
108 | * |
||
109 | * @param array $inserted |
||
110 | */ |
||
111 | 28 | private function saveInserted(array $inserted) |
|
119 | |||
120 | /** |
||
121 | * Save the updated entries. |
||
122 | * |
||
123 | * @param \Illuminate\Database\Eloquent\Collection $saved |
||
124 | * @param array $updated |
||
125 | */ |
||
126 | 28 | private function saveUpdated($saved, array $updated) |
|
137 | |||
138 | /** |
||
139 | * Save the deleted entries. |
||
140 | * |
||
141 | * @param \Illuminate\Database\Eloquent\Collection $saved |
||
142 | * @param array $deleted |
||
143 | */ |
||
144 | 28 | private function saveDeleted($saved, array $deleted) |
|
154 | } |
||
155 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: