PluginProbe
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution / trunk
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution vtrunk
2.4.0 2.3.0 2.2.5 2.2.0 2.1.2 2.1.1 trunk 1.10.0 1.10.01 1.10.02 1.5.0 1.5.01 1.5.02 1.5.1 1.5.10 1.5.20 1.5.21 1.5.22 1.5.23 1.5.24 1.5.25 1.6.0 1.7.0 1.7.1 1.7.2 All 33 releases
← All changes | app/Models/Calendar.php +20 -5 1.5.21trunk View file →
@@ -12,8 +12,10 @@
12 12 protected $table = 'fcal_calendars';
13 13
14 14 protected $guarded = ['id'];
15 15
16 + protected $metaCache = [];
17 +
16 18 protected $fillable = [
17 19 'hash',
18 20 'user_id',
19 21 'account_id',
@@ -170,13 +172,24 @@
170 172 }
171 173
172 174 public function getMeta($key, $default = null)
173 175 {
174 - $meta = Meta::where('object_type', 'Calendar')
175 - ->where('object_id', $this->id)
176 - ->where('key', $key)
177 - ->first();
176 + if ($this->relationLoaded('metas')) {
177 + $meta = $this->metas->firstWhere('key', $key);
178 + return $meta ? $meta->value : $default;
179 + }
178 180
181 + if (array_key_exists($key, $this->metaCache)) {
182 + $meta = $this->metaCache[$key];
183 + } else {
184 + $meta = Meta::where('object_type', 'Calendar')
185 + ->where('object_id', $this->id)
186 + ->where('key', $key)
187 + ->first();
188 +
189 + $this->metaCache[$key] = $meta;
190 + }
191 +
179 192 if (!$meta) {
180 193 return $default;
181 194 }
182 195
@@ -201,8 +214,10 @@
201 214 'value' => $value
202 215 ]);
203 216 }
204 217
218 + $this->metaCache[$key] = $exist;
219 +
205 220 return $exist;
206 221 }
207 222
208 223 public function getLandingPageUrl($isForce = false)
@@ -244,9 +259,9 @@
244 259 }
245 260
246 261 public static function getAllHosts()
247 262 {
248 - $calendars = self::with(['user'])
263 + $calendars = self::with(['user', 'metas'])
249 264 ->where('type', 'simple')
250 265 ->get();
251 266
252 267 $deletedUser = __('Deleted User', 'fluent-booking');