You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Apologies for bringing back a stale issue, but wanted to share this in case anyone else is looking for this feature.
You can accomplish this out-of-the-box via some creative Nova use:
Create a Nova resource to represent your Nova Notes, just like any other Nova resource. The more important part is setting the $search property to the fields you want to be able to search globally (probably the 'text' field). Once this resource is in place and registered with Nova, you will find it on the navigation sidebar (where you can view and perform a resource-specific search/filtering) and the notes will be globally searchable.
Hope this helps.
Here's some inspiration:
<?phpnamespaceApp\Nova;
useLaravel\Nova\Fields\BelongsTo;
useLaravel\Nova\Fields\Boolean;
useLaravel\Nova\Fields\DateTime;
useLaravel\Nova\Fields\ID;
useLaravel\Nova\Fields\MorphTo;
useLaravel\Nova\Fields\Text;
useLaravel\Nova\Fields\Trix;
useLaravel\Nova\Http\Requests\NovaRequest;
classNovaNoteextendsResource
{
publicstatic$model = \Outl1ne\NovaNotesField\Models\Note::class;
publicstatic$search = [
'text',
];
publicfunctionsubtitle(): ?string
{
return$this->text;
}
publicfunctionfields(NovaRequest$request): array
{
return [
ID::make()->sortable(),
MorphTo::make('Notable')
->types([
User::class,
])
->searchable(),
BelongsTo::make('Created By', 'createdBy', User::class)
->searchable(),
// This Text field is optional and is present so we can see the note on the Index page.Text::make('Text')
->onlyOnIndex()
->asHtml(),
// Could also use a Textarea field if you normally use that to write Nova notes.Trix::make('Text')
->alwaysShow()
->hideFromIndex(),
Boolean::make('System')->readonly(),
DateTime::make('Created At')->readonly(),
DateTime::make('Updated At')->readonly(),
];
}
// ...// Add any custom authorization, actions, filters, etc.
}
Hello,
is it possible to make te notes searchable trough the resource search?
thanks
The text was updated successfully, but these errors were encountered: