add nova
This commit is contained in:
43
nova/src/Fields/Color.php
Normal file
43
nova/src/Fields/Color.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Laravel\Nova\Fields;
|
||||
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
|
||||
class Color extends Field
|
||||
{
|
||||
use HasSuggestions;
|
||||
use 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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user