jsonSerialize(), function ($field) { $field['suggestions'] = $field['suggestions'] ?? $this->resolveSuggestions(app(NovaRequest::class)); return Arr::only($field, [ 'uniqueKey', 'name', 'attribute', 'suggestions', 'type', 'min', 'max', 'step', 'pattern', 'placeholder', 'extraAttributes', ]); }); } /** * Prepare the element for JSON serialization. * * @return array */ public function jsonSerialize(): array { $request = app(NovaRequest::class); if ($request->isFormRequest()) { return array_merge(parent::jsonSerialize(), [ 'suggestions' => $this->resolveSuggestions($request), ]); } return array_merge(parent::jsonSerialize(), [ 'asHtml' => $this->asHtml, 'copyable' => $this->copyable, ]); } }