<?php
namespace Laravel\Nova\Fields;
use Laravel\Nova\Http\Requests\NovaRequest;
class Color extends Field
{
use HasSuggestions, SupportsDependentFields;
/**
* The field's component.
*
* @var string
*/
public $component = 'color-field';
/**
* The text alignment for the field's text in tables.
*
* @var string
*/
public $textAlign = 'center';
/**
* Prepare the element for JSON serialization.
*
* @return array<string, mixed>
*/
public function jsonSerialize(): array
{
$request = app(NovaRequest::class);
if ($request->isFormRequest()) {
return array_merge(parent::jsonSerialize(), [
'suggestions' => $this->resolveSuggestions($request),
]);
}
return parent::jsonSerialize();
}
}