from = $from; return $this; } /** * Set the separator used for slugifying the field. * * @param string $separator * @return $this */ public function separator($separator) { $this->separator = $separator; return $this; } /** * Return a preview for the given field value. * * @param string $value * @return mixed */ public function previewFor($value) { return Str::slug($value, $this->separator); } /** * Prepare the element for JSON serialization. * * @return array */ public function jsonSerialize(): array { $request = app(NovaRequest::class); if ($request->isUpdateOrUpdateAttachedRequest()) { $this->readonly(); $this->showCustomizeButton = true; } return array_merge([ 'updating' => $request->isUpdateOrUpdateAttachedRequest(), 'from' => $this->from instanceof Field ? $this->from->attribute : str_replace(' ', '_', Str::lower((string) $this->from)), 'separator' => $this->separator, 'showCustomizeButton' => $this->showCustomizeButton, ], parent::jsonSerialize()); } }