| @@ -305,9 +305,9 @@ | ||
| 305 | 305 | if ($key == 'form_data_html') { |
| 306 | 306 | return __('will be available soon', 'fluent-booking'); |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | - return Arr::get($guest, $key, ''); | |
| 309 | + return self::resolveScalarAttribute($guest, $key); | |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | protected static function getBookingEventData($key) |
| 313 | 313 | { |
| @@ -318,13 +318,13 @@ | ||
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | $fillables = (new CalendarSlot())->getFillable(); |
| 321 | 321 | |
| 322 | - if (in_array($key, $fillables) || isset($bookingEvent->{$key})) { | |
| 322 | + if (in_array($key, $fillables)) { | |
| 323 | 323 | return $bookingEvent->{$key}; |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - return ''; | |
| 326 | + return self::resolveScalarAttribute($bookingEvent, $key); | |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | protected static function getCalendarData($key) |
| 330 | 330 | { |
| @@ -335,13 +335,28 @@ | ||
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | $fillables = (new Calendar())->getFillable(); |
| 338 | 338 | |
| 339 | - if (in_array($key, $fillables) || isset($calendar->{$key})) { | |
| 339 | + if (in_array($key, $fillables)) { | |
| 340 | 340 | return $calendar->{$key}; |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | - return ''; | |
| 343 | + return self::resolveScalarAttribute($calendar, $key); | |
| 344 | + } | |
| 345 | + | |
| 346 | + /** | |
| 347 | + * Resolve a scalar attribute only; never a relation (dumps as JSON) or a | |
| 348 | + * dotted hop into a relation's columns. | |
| 349 | + */ | |
| 350 | + protected static function resolveScalarAttribute($model, $key) | |
| 351 | + { | |
| 352 | + if (strpos($key, '.') !== false) { | |
| 353 | + return ''; | |
| 354 | + } | |
| 355 | + | |
| 356 | + $value = isset($model[$key]) ? $model[$key] : ''; | |
| 357 | + | |
| 358 | + return is_scalar($value) ? $value : ''; | |
| 344 | 359 | } |
| 345 | 360 | |
| 346 | 361 | protected static function getPaymentData($key) |
| 347 | 362 | { |