add nova
This commit is contained in:
96
nova/src/Fields/Trix.php
Normal file
96
nova/src/Fields/Trix.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace Laravel\Nova\Fields;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Laravel\Nova\Contracts\Deletable as DeletableContract;
|
||||
use Laravel\Nova\Contracts\FilterableField;
|
||||
use Laravel\Nova\Contracts\Storable as StorableContract;
|
||||
use Laravel\Nova\Fields\Filters\TextFilter;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
|
||||
class Trix extends Field implements DeletableContract, FilterableField, StorableContract
|
||||
{
|
||||
use Expandable;
|
||||
use FieldFilterable;
|
||||
use HasAttachments;
|
||||
use SupportsDependentFields;
|
||||
|
||||
/**
|
||||
* The field's component.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $component = 'trix-field';
|
||||
|
||||
/**
|
||||
* Indicates if the element should be shown on the index view.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $showOnIndex = false;
|
||||
|
||||
/**
|
||||
* Hydrate the given attribute on the model based on the incoming request.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @param string $requestAttribute
|
||||
* @param \Illuminate\Database\Eloquent\Model|\Laravel\Nova\Support\Fluent $model
|
||||
* @param string $attribute
|
||||
* @return void|\Closure
|
||||
*/
|
||||
protected function fillAttribute(NovaRequest $request, $requestAttribute, $model, $attribute)
|
||||
{
|
||||
return $this->fillAttributeWithAttachment($request, $requestAttribute, $model, $attribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the full path that the field is stored at on disk.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getStoragePath()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make the field filter.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return \Laravel\Nova\Fields\Filters\Filter
|
||||
*/
|
||||
protected function makeFilter(NovaRequest $request)
|
||||
{
|
||||
return new TextFilter($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the field for JSON serialization.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function serializeForFilter()
|
||||
{
|
||||
return transform($this->jsonSerialize(), function ($field) {
|
||||
return Arr::only($field, [
|
||||
'uniqueKey',
|
||||
'name',
|
||||
'attribute',
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the element for JSON serialization.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return array_merge(parent::jsonSerialize(), [
|
||||
'shouldShow' => $this->shouldBeExpanded(),
|
||||
'withFiles' => $this->withFiles,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user